* { margin: 0; padding: 0; box-sizing: border-box; }
:root { --rs-font: 'MedievalSharp', serif; --rs-panel-bg: #0F0703; --rs-text: #ff981f; --rs-accent-bg: #3E2723; --rs-accent-border: #2D1A0F; --rs-accent-hover: #5D4037; --rs-upload-bg: #2F1E0C; --rs-upload-hover-bg: #3E2723; }
.rs-box { background: var(--rs-panel-bg); color: var(--rs-text); font-family: var(--rs-font); border-radius: 0; padding: 8px; }
header, header h1, header p, .left-sidebar h3, .right-sidebar h4, .hat-item span, .control-group label, .control-group span { color: var(--rs-text); font-family: var(--rs-font); }
body { position: relative; perspective: 1000px; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; min-height: 100vh; width: 100%; color: #333; z-index: 0; overflow-x: auto; overflow-y: visible; display: flex; justify-content: center; align-items: center; }
body::before, body::after { content: ''; position: absolute; top: -50%; left: -50%; width: 200%; height: 200%; background-size: auto; background-position: 0 0; background-repeat: repeat; animation: scrollDiagonally 600s linear infinite; transform-origin: center; }
body::before { background-image: url('assets/tiledbg.png'); opacity: 0.3; z-index: -1; }
body::after { background-image: url('assets/mapbgimage.jpg'); mix-blend-mode: blend; opacity: 1; z-index: -2; pointer-events: none; }
@media (max-width: 768px) and (orientation: portrait), (max-height: 768px) and (orientation: portrait) {
  html { overflow-x: hidden; max-width: 100vw; position: relative; }
  body { min-width: auto; width: 100%; overflow: auto; justify-content: flex-start; align-items: flex-start; perspective: none; padding: 0 0 80px; max-width: 100vw; position: relative; height: 100vh; max-height: 100vh; }
  .container { width: 100%; max-width: 100vw; overflow-x: hidden; padding: 15px 5px 80px; margin: 0 auto; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; min-height: auto; max-height: 100vh; overflow-y: auto; }
  .editor-layout { flex-direction: column; align-items: center; width: 100%; min-width: auto; padding: 5px; max-width: 100vw; margin: 0 auto; flex-wrap: wrap; min-height: auto; height: auto; flex: 0 1 auto; overflow: visible; background: none; }
  .main-editor { order: -1; width: 100%; min-width: auto; max-width: 100vw; margin: 0 auto; display: flex; flex-direction: column; align-items: center; min-height: auto; max-height: calc(100vh - 200px); flex: 0 1 auto; justify-content: flex-start; padding: 10px; overflow: visible; }
  .upload-area { flex: none; min-height: 120px; max-height: 150px; width: 100%; height: 130px; margin: 5px 0; }
  .upload-content { padding: 10px; height: 100%; display: flex; flex-direction: column; justify-content: center; align-items: center; }
  .upload-content p { font-size: 0.8em; margin: 5px 0; text-align: center; }
  .left-sidebar, .right-sidebar { display: none; }
  .hat-gallery { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); }
  header h1 { font-size: 1.5em; white-space: normal; margin-bottom: 5px; }
  header p { font-size: 0.9em; white-space: normal; margin-bottom: 10px; }
  .control-group label { white-space: normal; }
  .mobile-toolbar { display: flex !important; position: fixed; bottom: env(safe-area-inset-bottom); padding-bottom: calc(env(safe-area-inset-bottom) + 8px); top: auto; }
  .mobile-toolbar .toolbar-section { padding: 8px 12px; }
  .mobile-toolbar span { font-size: 12px; }
  .toolbar-icon { font-size: 18px; margin-bottom: 4px; }
  .canvas-container { flex: none; width: 100%; max-width: 100vw; overflow: hidden; min-height: auto; height: auto; max-height: calc(100vh - 250px); margin-bottom: 10px; }
  #mainCanvas { max-width: 100%; height: auto; max-height: 60vh; object-fit: contain; }
}
.mobile-toolbar { display: none; position: fixed; bottom: 0; left: 0; right: 0; background: var(--rs-panel-bg) url('assets/tiledbg.png') repeat center center; background-size: auto; border-top: 2px solid var(--rs-accent-border); padding: 8px 0 16px; z-index: 9999; box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3); width: 100vw; height: 78px; }
.mobile-toolbar .toolbar-section { display: flex; flex-direction: column; align-items: center; flex: 1; padding: 8px 4px; cursor: pointer; transition: all 0.2s ease; border-radius: 8px; margin: 0 2px; }
.mobile-toolbar .toolbar-section:hover { background: rgba(255, 255, 255, 0.1); }
.toolbar-icon { font-size: 24px; margin-bottom: 2px; }
.mobile-toolbar .toolbar-icon img { width: 24px; height: 24px; }
.mobile-toolbar span { font-size: 10px; color: #e2e8f0; text-align: center; font-weight: 500; }
.toolbar-bard-icon { width: auto; height: 32px; object-fit: contain; margin: -4px 0 2px; animation: bardSway 3s ease-in-out infinite, bardFadeIn 2s ease-out; }
.mobile-tool-containers { display: none; position: fixed; bottom: 78px; left: 0; right: 0; z-index: 999; max-height: 60vh; overflow-y: auto; width: 100vw; pointer-events: none; }
.tool-container { pointer-events: auto; display: none; background: var(--rs-panel-bg) url('assets/tiledbg.png') repeat center center; background-size: auto; border: 2px solid var(--rs-accent-border); border-radius: 12px; margin: 8px; padding: 16px; box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4); }
.tool-container.active { display: block; }
.container-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; padding-bottom: 8px; border-bottom: 1px solid #4a5568; }
.container-header h3 { color: var(--rs-text); font-family: var(--rs-font); font-size: 18px; margin: 0; font-weight: bold; }
.close-tool { background: none; border: none; color: #e2e8f0; font-size: 24px; cursor: pointer; padding: 4px 8px; border-radius: 4px; transition: background 0.2s ease; }
.close-tool:hover { background: rgba(255, 255, 255, 0.1); }
.hat-gallery-mobile { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.hat-item-mobile { display: flex; flex-direction: column; align-items: center; padding: 12px 8px; background: rgba(255, 255, 255, 0.05); border: 2px solid transparent; border-radius: 8px; cursor: pointer; transition: all 0.2s ease; }
.hat-item-mobile:hover { background: rgba(255, 255, 255, 0.1); border-color: #4299e1; }
.hat-item-mobile img { width: 32px; height: 32px; margin-bottom: 4px; }
.hat-item-mobile span { font-size: 10px; color: #e2e8f0; text-align: center; }
.add-new-phat, .add-new-phat-mobile { display: flex; align-items: center; justify-content: center; background: var(--rs-accent-bg); border: 2px dashed var(--rs-text); border-radius: 8px; text-align: center; }
.add-new-phat { min-height: 80px; }
.add-new-phat-mobile { min-height: 60px; }
.add-new-phat span, .add-new-phat-mobile span { color: var(--rs-text); font-family: var(--rs-font); font-weight: bold; }
.add-new-phat span { font-size: 14px; }
.add-new-phat-mobile span { font-size: 12px; }
.style-selector-mobile h4 { color: var(--rs-text); font-family: var(--rs-font); font-size: 14px; margin-bottom: 8px; text-align: center; font-weight: bold; }
.style-buttons-mobile { display: flex; justify-content: center; gap: 8px; }
.style-btn-mobile { width: 40px; height: 40px; background: rgba(255, 255, 255, 0.1); border: 2px solid #4a5568; border-radius: 8px; color: #e2e8f0; font-weight: bold; cursor: pointer; transition: all 0.2s ease; }
.style-btn-mobile:hover { background: rgba(255, 255, 255, 0.2); }
.style-btn-mobile.active { background: #4299e1; border-color: #3182ce; }
.controls-mobile { display: flex; flex-direction: column; gap: 24px; padding: 16px; }
.controls-mobile label { color: var(--rs-text); font-family: var(--rs-font); font-weight: bold; font-size: 14px; }
.control-group-mobile { display: flex; align-items: center; margin: 32px 0; }
.control-group-mobile::before { content: attr(data-label); margin-right: 12px; color: var(--rs-text); font-family: var(--rs-font); font-weight: bold; flex: 0 0 auto; font-size: 1em; }
.control-group-mobile input[type="range"] { flex: 1; max-width: 200px; }
.control-group-mobile input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 32px; height: 32px; background: #4299e1; border: none; border-radius: 50%; cursor: pointer; margin-top: -13px; }
.control-group-mobile input[type="range"]::-moz-range-thumb { width: 32px; height: 32px; background: #4299e1; border: none; border-radius: 50%; cursor: pointer; }
.btn-delete-mobile, .btn-action-mobile, .btn-nostalgia-mobile { width: 100%; padding: 12px 16px; border: none; border-radius: 8px; font-size: 14px; font-weight: 500; cursor: pointer; transition: all 0.2s ease; margin-bottom: 8px; color: #fff; }
.btn-delete-mobile { background: linear-gradient(135deg, #e53e3e 0%, #c53030 100%); }
.btn-delete-mobile:hover { background: linear-gradient(135deg, #f56565 0%, #e53e3e 100%); }
.btn-action-mobile { background: linear-gradient(135deg, #4299e1 0%, #3182ce 100%); }
.btn-action-mobile:hover { background: linear-gradient(135deg, #63b3ed 0%, #4299e1 100%); }
.btn-nostalgia-mobile { background: linear-gradient(135deg, #9f7aea 0%, #805ad5 100%); font-family: var(--rs-font); }
.btn-nostalgia-mobile:hover { background: linear-gradient(135deg, #b794f4 0%, #9f7aea 100%); }
.btn-nostalgia-mobile.active { background: linear-gradient(135deg, #f6ad55 0%, #ed8936 100%); animation: pulse 2s infinite; }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }
@keyframes bardSway { 0%, 100% { transform: rotate(0deg); } 25% { transform: rotate(-3deg); } 75% { transform: rotate(3deg); } }
@keyframes bardFadeIn { 0% { opacity: 0; transform: scale(0.8); } 100% { opacity: 1; transform: scale(1); } }
@media (max-width: 768px) {
  .control-group-mobile label { display: none; }
  .canvas-controls { display: none !important; }
  details summary { background: var(--rs-panel-bg); color: var(--rs-text); padding: 8px 12px; border-radius: 6px; cursor: pointer; }
  details { margin-bottom: 8px; }
}
.control-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.control-row.button-row { gap: 12px; }
.control-row.button-row button { flex: 1; }
.control-row label { color: var(--rs-text); font-family: var(--rs-font); font-weight: bold; font-size: 12px; min-width: 40px; }
.control-row input[type="range"] { flex: 1; min-width: 0; }
.mobile-device .canvas-controls { display: none !important; }
@media (orientation: landscape) {
  .mobile-device .left-sidebar, .mobile-device .right-sidebar { display: none; }
  html, body { margin: 0; padding: 0; width: 100%; max-width: 100vw; overflow-x: hidden; position: relative; }
  body { background: var(--rs-panel-bg) url('assets/tiledbg.png') repeat; background-size: auto; }
  .mobile-device .editor-layout { flex-direction: column; align-items: center; background: none; }
  .mobile-device body { overflow: visible; background: var(--rs-panel-bg) url('assets/tiledbg.png') repeat; background-size: auto; }
  .mobile-device header { padding: 5px 10px; margin-bottom: 5px; }
  .mobile-device header h1 { font-size: 1.2em; margin: 0; line-height: 1.2; }
  .mobile-device .header-phat { width: 20px; height: 20px; }
  .mobile-device .main-editor { order: -1; width: auto; min-width: 300px; max-width: calc(100vw - 150px); margin: 0 auto; display: flex; flex-direction: column; align-items: center; min-height: auto; max-height: calc(100vh - 80px); flex: 0 1 auto; justify-content: flex-start; padding: 5px; overflow: visible; }
  .mobile-device .mobile-toolbar { display: flex !important; position: fixed; left: 0; top: 0; bottom: 0; right: auto; width: calc(80px + env(safe-area-inset-left)); height: 100vh; flex-direction: column; justify-content: flex-start; padding: 10px 0; z-index: 1000; padding-left: env(safe-area-inset-left); background: var(--rs-panel-bg) url(assets/tiledbg.png) repeat; background-size: auto; align-items: center; }
  .mobile-device .mobile-toolbar .toolbar-section { padding: 12px 8px; margin-bottom: 5px; flex-direction: column; min-height: auto; }
  .mobile-device .mobile-toolbar .toolbar-icon { font-size: 20px; margin-bottom: 4px; }
  .mobile-device .mobile-toolbar span { font-size: 9px; text-align: center; line-height: 1.1; max-width: 60px; word-wrap: break-word; }
  .mobile-device .container { margin-left: calc(80px + env(safe-area-inset-left)); width: calc(100% - 80px - env(safe-area-inset-left)); max-width: calc(100vw - 80px - env(safe-area-inset-left)); display: flex; flex-direction: column; align-items: center; justify-content: flex-start; overflow: visible; padding: 0; }
  .mobile-device .editor-layout { margin-left: 0; width: auto; max-width: calc(100vw - 150px); min-width: 300px; }
  .mobile-device .mobile-tool-containers { left: calc(80px + env(safe-area-inset-left)); width: calc(45vw - 80px - env(safe-area-inset-left)); max-width: calc(45vw - 80px - env(safe-area-inset-left)); max-height: 98vh; }
  .mobile-device #mainCanvas { width: auto; height: auto; max-height: calc(100vh - 80px); max-width: calc(100vw - 200px); object-fit: contain; }
  .mobile-device .upload-area { flex: none; min-height: 80px; max-height: 100px; width: 100%; height: 90px; margin: 5px 0; }
  .mobile-device .upload-content { padding: 5px; height: 100%; display: flex; flex-direction: column; justify-content: center; align-items: center; }
  .mobile-device .upload-content p { font-size: 0.7em; margin: 2px 0; }
  .mobile-device .canvas-container { flex: none; width: 100%; max-width: calc(100vw - 150px); overflow: visible; min-height: auto; height: auto; max-height: calc(100vh - 80px); margin-bottom: 5px; display: flex; justify-content: center; align-items: center; }
  .mobile-device .long-press-hint-container { width: 100%; max-width: calc(100vw - 150px); text-align: center; margin: 5px 0; display: flex; justify-content: center; align-items: center; }
  .mobile-device .long-press-hint { font-size: 11px; padding: 4px 16px; margin: 0 auto; display: block; text-align: center; white-space: nowrap; max-width: 90%; }
  .mobile-device .tool-container { margin: 8px 4px; padding: 12px 8px; max-height: 98vh; overflow-y: auto; }
  .mobile-device .controls-mobile { gap: 8px; }
  .mobile-device .control-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
  .mobile-device .control-row label { min-width: 35px; font-size: 11px; color: var(--rs-text); font-family: var(--rs-font); font-weight: bold; }
  .mobile-device .control-row input[type="range"] { flex: 1; min-width: 0; }
  .mobile-device .controls-mobile label { color: var(--rs-text); font-family: var(--rs-font); font-size: 11px; font-weight: bold; }
  .mobile-device .container-header h3 { color: var(--rs-text); font-family: var(--rs-font); }
  .mobile-device .style-selector-mobile h4 { color: var(--rs-text); font-family: var(--rs-font); }
  .mobile-device .hat-gallery-mobile { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
  .mobile-device .hat-item-mobile { padding: 8px 4px; }
  .mobile-device .hat-item-mobile img { width: 24px; height: 24px; margin-bottom: 2px; }
  .mobile-device .hat-item-mobile span { font-size: 9px; }
  .mobile-device .add-new-phat-mobile { min-height: 48px; }
  .mobile-device .add-new-phat-mobile span { font-size: 10px; }
  .mobile-device .btn-delete-mobile, .mobile-device .btn-action-mobile, .mobile-device .btn-nostalgia-mobile { width: 85%; max-width: 200px; }
}
@media (max-width: 768px) and (orientation: portrait) {
  .mobile-toolbar { bottom: env(safe-area-inset-bottom); transition: transform 0.3s ease, bottom 0.3s ease; }
  html, body { margin: 0; padding: 0; width: 100%; max-width: 100vw; overflow-x: hidden; }
  .container { margin: 0; padding: 0; width: 100%; max-width: 100vw; }
}
input[type="range"] { -webkit-appearance: none; background: var(--rs-accent-bg); height: 6px; accent-color: var(--rs-text); touch-action: pan-x; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 24px; height: 24px; background: var(--rs-text); border: none; border-radius: 50%; margin-top: -9px; cursor: pointer; }
input[type="range"]::-moz-range-thumb { width: 24px; height: 24px; background: var(--rs-text); border: none; border-radius: 50%; cursor: pointer; }
.control-group span, .control-group-mobile span, #sizeValue, #rotationValue, #positionXValue, #positionYValue, #sizeValueMobile, #rotationValueMobile, #positionXValueMobile, #positionYValueMobile { display: none; }
.mobile-toolbar, .tool-container, details summary, .controls-mobile { touch-action: manipulation; }
details[open] > summary { display: none; }
.btn-primary, .btn-secondary, .btn-delete, .btn-nostalgia { background: var(--rs-accent-bg); color: var(--rs-text); border: none; padding: 12px 24px; border-radius: 8px; cursor: pointer; transition: background 0.3s; }
.btn-primary:hover, .btn-secondary:hover, .btn-delete:hover, .btn-nostalgia:hover { background: var(--rs-accent-hover); }
.btn-nostalgia { border: 1px solid var(--rs-accent-border); padding: 12px 16px; border-radius: 5px; font-family: var(--rs-font); }
html { background-color: var(--rs-panel-bg); }
@media (min-width: 769px) {
  html, body { overflow: hidden; }
  body:not(.mobile-device) { overflow: hidden; }
}
html, body { overflow: visible; overscroll-behavior: contain; touch-action: none; -webkit-user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; position: relative; }
.auto-clean-toggle { padding: 8px 12px !important; width: 180px !important; margin: 6px 0 !important; }
.auto-clean-toggle.enabled { background: var(--rs-accent-bg) !important; color: var(--rs-text) !important; border-color: var(--rs-accent-border) !important; }
.auto-clean-toggle.disabled { background: #dc3545 !important; color: white !important; border-color: #dc3545 !important; }
.auto-clean-toggle:hover.enabled { background: var(--rs-accent-hover) !important; }
.auto-clean-toggle:hover.disabled { background: #e74c3c !important; }
.auto-clean-toggle-mobile.enabled { background: #28a745 !important; color: white !important; }
.auto-clean-toggle-mobile.disabled { background: #dc3545 !important; color: white !important; }
.wave-text, .wave-char { display: inline-block; }
.wave-char { animation: wave2 2s ease-in-out infinite; }
@keyframes wave2 { 0%, 100% { transform: translateY(0); } 25% { transform: translateY(-8px); } 75% { transform: translateY(8px); } }
.wave-char:nth-child(1) { animation-delay: 0s; } .wave-char:nth-child(2) { animation-delay: 0.1s; } .wave-char:nth-child(3) { animation-delay: 0.2s; } .wave-char:nth-child(4) { animation-delay: 0.3s; } .wave-char:nth-child(5) { animation-delay: 0.4s; } .wave-char:nth-child(6) { animation-delay: 0.5s; } .wave-char:nth-child(7) { animation-delay: 0.6s; } .wave-char:nth-child(8) { animation-delay: 0.7s; } .wave-char:nth-child(9) { animation-delay: 0.8s; } .wave-char:nth-child(10) { animation-delay: 0.9s; } .wave-char:nth-child(11) { animation-delay: 1.0s; } .wave-char:nth-child(12) { animation-delay: 1.1s; } .wave-char:nth-child(13) { animation-delay: 1.2s; } .wave-char:nth-child(14) { animation-delay: 1.3s; } .wave-char:nth-child(15) { animation-delay: 1.4s; } .wave-char:nth-child(16) { animation-delay: 1.5s; } .wave-char:nth-child(17) { animation-delay: 1.6s; } .wave-char:nth-child(18) { animation-delay: 1.7s; } .wave-char:nth-child(19) { animation-delay: 1.8s; } .wave-char:nth-child(20) { animation-delay: 1.9s; } .wave-char:nth-child(21) { animation-delay: 2.0s; } .wave-char:nth-child(22) { animation-delay: 2.1s; } .wave-char:nth-child(23) { animation-delay: 2.2s; } .wave-char:nth-child(24) { animation-delay: 2.3s; } .wave-char:nth-child(25) { animation-delay: 2.4s; }
header, header h1, header p { text-align: center; }
header { padding: 25px 15px 10px; margin-bottom: 2px; }
.exclamation-char { font-family: 'Times New Roman', serif; font-weight: bold; font-size: 1.1em; text-shadow: 2px 2px 4px rgba(0,0,0,0.3); }
header h1 { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; width: 100%; white-space: normal; overflow: visible; line-height: 1.2; font-size: 14px; gap: 2px; }
.header-phat { width: 18px; height: 18px; margin: 0 1px; }
@media (max-width: 768px) {
  header { padding: 25px 15px 10px; }
  header h1 { font-size: 20px; line-height: 1.1; white-space: nowrap; overflow: visible; text-overflow: ellipsis; }
  .header-phat { width: 24px; height: 24px; margin: 0 4px; }
}
@media (max-width: 480px) {
  header h1 { font-size: 16px; gap: 4px; }
  .header-phat { width: 20px; height: 20px; margin: 0 2px; }
}
@media (max-width: 320px) {
  header h1 { font-size: 12px; gap: 1px; }
  .header-phat:last-child { display: none; }
}
@media (min-width: 769px) {
  header h1 { font-size: clamp(20px, 2.5vw, 28px); gap: 8px; }
  .header-phat { width: clamp(24px, 3vw, 32px); height: clamp(24px, 3vw, 32px); margin: 0 8px; }
}
@media (min-width: 769px) and (max-width: 1200px) {
  body:not(.mobile-device) .editor-layout { padding: 20px 25px; }
  body:not(.mobile-device) .left-sidebar, body:not(.mobile-device) .right-sidebar { width: 200px; min-width: 200px; }
  body:not(.mobile-device) .main-editor { margin: 0 20px; padding: 20px; }
}
#canvasContainer, #mainCanvas { touch-action: none; -webkit-user-select: none; user-select: none; }
.canvas-container { touch-action: none; display: flex; justify-content: center; align-items: center; width: 100%; }
.long-press-hint-container { width: 100%; text-align: center; margin: 15px 0 10px; z-index: 500; pointer-events: none; }
.long-press-hint { font-size: 14px; color: var(--rs-text); background: var(--rs-panel-bg); padding: 8px 32px; border-radius: 6px; border: 1px solid var(--rs-accent-border); display: inline-block; margin: 0; animation: longPressHintPulse 2s infinite; font-family: var(--rs-font); box-shadow: 0 2px 8px rgba(0,0,0,0.3); text-align: center; white-space: nowrap; backdrop-filter: blur(4px); width: auto; max-width: 90%; }
@keyframes longPressHintPulse { 0%, 100% { opacity: 0.8; transform: scale(1); } 50% { opacity: 1; transform: scale(1.02); } }
@media (max-width: 768px) {
  .long-press-hint-container { margin: 10px 0; }
  .long-press-hint { font-size: 12px; padding: 6px 24px; max-width: 95%; }
}
body:not(.mobile-device) { width: 100%; overflow: hidden; justify-content: center; align-items: flex-start; padding: 20px; }
body:not(.mobile-device) .container { width: 100%; max-width: min(1400px, 95vw); margin: 0 auto; padding: 0; display: block; }
body:not(.mobile-device) .editor-layout { display: flex; gap: 0; align-items: flex-start; width: 100%; background: url('assets/phatUImainpanel.png') no-repeat center center; background-size: 100% 100%; padding: 40px 50px; margin: 20px auto; min-height: 600px; border-radius: 0; max-width: 1400px; }
body:not(.mobile-device) .left-sidebar, body:not(.mobile-device) .right-sidebar { display: block; width: 250px; min-width: 250px; flex-shrink: 0; background: none; border: none; box-shadow: none; }
body:not(.mobile-device) .main-editor { flex: 1; min-width: min(600px, 50vw); max-width: none; height: auto; order: 0; background: rgba(15, 7, 3, 0.3); border: 2px solid var(--rs-accent-border); border-radius: 8px; margin: 0 30px; padding: 30px; display: flex; flex-direction: column; align-items: center; min-height: 400px; }
body:not(.mobile-device) .mobile-toolbar { display: none !important; }
body:not(.mobile-device) .mobile-tool-containers { display: none !important; }
body:not(.mobile-device) .canvas-controls { display: flex; gap: 15px; justify-content: center; margin-top: 20px; flex-wrap: wrap; width: 100%; }
body:not(.mobile-device) .hat-gallery { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 20px; }
body:not(.mobile-device) .hat-item { display: flex; flex-direction: column; align-items: center; padding: 8px; border: 2px solid var(--rs-accent-border); border-radius: 6px; cursor: pointer; transition: background-color 0.3s; }
body:not(.mobile-device) .hat-item:hover { background-color: var(--rs-accent-bg); }
body:not(.mobile-device) .hat-preview img { width: 40px; height: 40px; object-fit: contain; }
body:not(.mobile-device) .control-group { display: flex; flex-direction: column; margin-bottom: 15px; }
body:not(.mobile-device) .control-group label { margin-bottom: 5px; font-size: 14px; }
body:not(.mobile-device) .control-group input[type="range"] { width: 100%; margin-bottom: 5px; }
body:not(.mobile-device) .style-buttons { display: flex; gap: 8px; justify-content: center; }
body:not(.mobile-device) .style-btn { padding: 8px 16px; background: var(--rs-accent-bg); color: var(--rs-text); border: none; border-radius: 4px; cursor: pointer; transition: background-color 0.3s; }
body:not(.mobile-device) .style-btn:hover { background: var(--rs-accent-hover); }
body:not(.mobile-device) .style-btn.active { background: var(--rs-text); color: var(--rs-panel-bg); }
body:not(.mobile-device) .rs-box { background: none; border: none; padding: 20px; }
body:not(.mobile-device) .upload-area { display: flex; flex: 1; width: 100%; align-items: center; justify-content: center; }
body:not(.mobile-device) .upload-content { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; width: 100%; border: 2px dashed var(--rs-accent-border); border-radius: 6px; padding: 40px 20px; background: rgba(62, 39, 35, 0.2); min-height: 160px; }
body:not(.mobile-device) .upload-content p { margin-bottom: 15px; font-size: 16px; }
body:not(.mobile-device) .canvas-container { display: flex; flex: 1; width: 100%; flex-direction: column; align-items: center; justify-content: center; }
body:not(.mobile-device) #mainCanvas { max-width: 100%; max-height: 400px; width: auto; height: auto; object-fit: contain; border-radius: 4px; }
body:not(.mobile-device) h3, body:not(.mobile-device) h4 { margin-bottom: 15px; }
body:not(.mobile-device) .btn-delete, body:not(.mobile-device) .btn-nostalgia { width: 180px; padding: 8px 12px; margin: 6px 0; font-family: var(--rs-font); border-radius: 4px; background: var(--rs-accent-bg); color: var(--rs-text); border: 1px solid var(--rs-accent-border); cursor: pointer; transition: background 0.3s; display: flex; align-items: center; justify-content: center; gap: 8px; }
body:not(.mobile-device) .btn-delete:hover, body:not(.mobile-device) .btn-nostalgia:hover { background: var(--rs-accent-hover); }
body:not(.mobile-device) .desktop-bard-icon { width: 48px; height: 48px; margin: 0; animation: bardSway 12s cubic-bezier(0.25, 0.46, 0.45, 0.94) infinite, bardFadeIn 2s ease-out; transform-origin: center bottom; will-change: transform; }
body:not(.mobile-device) .long-press-hint-container { display: none; }
body:not(.mobile-device) .long-press-hint { background: rgba(15, 7, 3, 0.8); border: 1px solid var(--rs-accent-border); }
@supports (padding-top: env(safe-area-inset-top)) {
  body { padding-top: env(safe-area-inset-top); padding-left: 0; padding-right: 0; }
  .mobile-toolbar { bottom: env(safe-area-inset-bottom); padding-bottom: calc(env(safe-area-inset-bottom) + 8px); padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
  .container { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
  .mobile-tool-containers { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
}
@media screen and (max-width: 768px) {
  body { -webkit-overflow-scrolling: touch; overscroll-behavior-y: none; min-height: 100vh; min-height: -webkit-fill-available; position: relative; }
  html { height: 100%; -webkit-text-size-adjust: 100%; min-height: -webkit-fill-available; position: relative; }
  * { -webkit-tap-highlight-color: rgba(0, 0, 0, 0); -webkit-touch-callout: none; }
}