:root {
  --ui: rgba(18, 25, 22, .88);
  --line: #ffffff38;
  --txt: #f5f7ee;
  --accent: #a8dc73;
  --btn: clamp(38px, 6.5vw, 58px);
  --ui-size: 52px;
  --controls-opacity: .85;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; background: #101a14; color: var(--txt); font-family: system-ui, -apple-system, Segoe UI, Arial, sans-serif; touch-action: none; overscroll-behavior: none; }
button, canvas, #game, #hud { touch-action: none; -webkit-user-select: none; user-select: none; }
button { font: inherit; color: inherit; cursor: pointer; border: 1px solid var(--line); background: #28372c; border-radius: 10px; padding: 10px 13px; font-weight: 750; }
button:active { filter: brightness(1.25); transform: scale(.98); }
.hidden { display: none !important; }
#game { position: fixed; inset: 0; display: none; background: #8ac7ef; }
#view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; outline: none; }
#menu { position: fixed; inset: 0; overflow: auto; display: grid; place-items: center; padding: 20px; background: linear-gradient(#101a14bb, #101a14ef), linear-gradient(135deg, #6c9d52, #24462d 55%, #1a2b20); touch-action: pan-y; }
#startScreen { position: fixed; inset: 0; z-index: 20; overflow: hidden; background: #101a14 url("/manus-storage/2ca85fc0-c8f9-11f1-b977-5506f618a80a_fe22ebc2.png") center center / cover no-repeat; }
.start-hit { position: absolute; left: 50%; width: min(95vw, 45vh); height: 12.8vh; transform: translateX(-50%); border: 0; background: transparent; border-radius: 14px; padding: 0; touch-action: manipulation; box-shadow: none; }
#startPlayBtn { top: 43.4%; }
#startOptionsBtn { top: 57.7%; }
.start-hit:active { transform: translateX(-50%) scale(.98); filter: brightness(1.15); }
.start-hit:focus-visible { outline: 4px solid #fff; background: #ffffff20; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.menu-card { width: min(560px, 100%); max-height: calc(100dvh - 32px); overflow: auto; background: #17251df2; border: 1px solid #ffffff2a; border-radius: 22px; padding: clamp(18px, 4vw, 30px); box-shadow: 0 20px 70px #0007; touch-action: pan-y; }
.brand { display: flex; align-items: center; gap: 13px; margin-bottom: 7px; }
.logo { width: 53px; height: 53px; display: grid; place-items: center; background: #8dc65c; color: #20341d; border: 4px solid #d2e8b8; border-radius: 10px; font-size: 28px; box-shadow: inset -7px -7px #4c7a3e; }
.brand h1 { font-size: clamp(29px, 7vw, 43px); letter-spacing: -1.5px; margin: 0; line-height: 1; }
.sub { color: #bdcbbd; margin: 12px 0 20px; line-height: 1.5; }
.menugroup { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.primary { background: #8dc65c; color: #172516; border-color: #b7e58a; }
.wide { width: 100%; margin-top: 10px; }
.tiny { font-size: 12px; color: #aebdac; line-height: 1.5; margin-top: 15px; }
.settings { display: grid; gap: 13px; margin-top: 15px; }
.setting { display: grid; grid-template-columns: 1fr minmax(130px, 48%); align-items: center; gap: 12px; }
.setting label { font-weight: 700; font-size: 14px; }
.setting select, .setting input { width: 100%; background: #101a14; color: #fff; border: 1px solid var(--line); border-radius: 9px; padding: 10px; }
.setting input[type="range"] { padding: 0; accent-color: #9ed86d; touch-action: pan-x; }
.control-preview { position: relative; height: 176px; margin: 8px 0 3px; overflow: hidden; border: 1px solid #ffffff40; border-radius: 12px; background: linear-gradient(135deg, #24352b, #101913); touch-action: none; }
.control-preview::after { content: "TELA DE JOGO"; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); color: #ffffff5c; font-size: 10px; letter-spacing: 2px; pointer-events: none; }
.control-preview button { position: relative; z-index: 1; width: var(--preview-size, 28px); height: var(--preview-size, 28px); padding: 0; display: grid; place-items: center; border-radius: 6px; background: #66804d; border: 1px solid #ffffff90; font-size: 10px; touch-action: none; opacity: var(--controls-opacity); }
.preview-pad { position: absolute; z-index: 2; left: 12px; bottom: 12px; display: grid; grid-template-columns: repeat(3, var(--preview-size, 28px)); grid-template-rows: repeat(3, var(--preview-size, 28px)); gap: 3px; }
.preview-pad [data-preview-id="forward"] { grid-column: 2; grid-row: 1; }
.preview-pad [data-preview-id="left"] { grid-column: 1; grid-row: 2; }
.preview-pad [data-preview-id="crouch"] { grid-column: 2; grid-row: 2; font-size: 7px; }
.preview-pad [data-preview-id="right"] { grid-column: 3; grid-row: 2; }
.preview-pad [data-preview-id="back"] { grid-column: 2; grid-row: 3; }
.preview-actions { position: absolute; z-index: 2; right: 12px; bottom: 12px; display: grid; grid-template-columns: repeat(2, var(--preview-size, 42px)); gap: 4px; }
.preview-actions button { width: var(--preview-size, 42px); height: var(--preview-size, 42px); font-size: 6px; }
.preview-joystick { display: none; position: absolute; left: 16px; bottom: 16px; z-index: 2; width: calc(var(--preview-size, 38px) + var(--preview-size, 38px)); height: calc(var(--preview-size, 38px) + var(--preview-size, 38px)); border: 2px solid #ffffff80; border-radius: 50%; background: #ffffff24; touch-action: none; }
.preview-joystick span { position: absolute; left: 50%; top: 50%; width: var(--preview-size, 38px); height: var(--preview-size, 38px); transform: translate(-50%, -50%); border: 2px solid #ffffffa0; border-radius: 50%; background: #7e9f5fcc; }
.control-preview.joystick-mode .preview-pad { display: none; }
.control-preview.joystick-mode .preview-joystick { display: block; }
#hud { position: absolute; inset: 0; pointer-events: none; }
.topline { position: absolute; left: 10px; right: 10px; top: 10px; display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.pill { background: var(--ui); border: 1px solid var(--line); border-radius: 10px; padding: 8px 11px; font-size: 12px; box-shadow: 0 3px 12px #0002; }
.topline button { pointer-events: auto; padding: 8px 10px; }
.crosshair { position: absolute; left: 50%; top: 50%; width: 18px; height: 18px; transform: translate(-50%, -50%); opacity: .9; }
.crosshair:before, .crosshair:after { content: ""; position: absolute; background: #fff; box-shadow: 0 1px 2px #000; }
.crosshair:before { width: 2px; height: 18px; left: 8px; }
.crosshair:after { height: 2px; width: 18px; top: 8px; }
#survivalBars { position: absolute; left: 50%; bottom: calc(max(8px, env(safe-area-inset-bottom)) + 69px); transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 3px; pointer-events: none; text-shadow: 1px 1px 2px #000; white-space: nowrap; }
#healthBar, #hungerBar { font-size: clamp(15px, 2.8vw, 22px); letter-spacing: 1px; line-height: 1.05; filter: drop-shadow(1px 1px 1px #222); }
#hungerBar { font-size: clamp(14px, 2.6vw, 21px); }
#hotbar { position: absolute; bottom: max(8px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); display: flex; gap: 4px; pointer-events: auto; max-width: 96vw; overflow-x: auto; padding: 5px; background: #111a16c9; border: 1px solid #ffffff30; border-radius: 12px; }
.slot { width: clamp(39px, 7vw, 54px); height: clamp(44px, 8vw, 60px); flex: 0 0 auto; padding: 3px; border-radius: 7px; background: #26332ac9; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; position: relative; }
.slot.empty { background: #162019b8; border-style: dashed; opacity: .7; }
.slot.selected { outline: 3px solid #d7f59c; background: #526744; }
.swatch { width: 22px; height: 22px; border: 2px solid #ffffff60; box-shadow: inset -5px -5px #0002; border-radius: 3px; }
.mc-icon { width: 24px; height: 24px; display: block; object-fit: contain; image-rendering: pixelated; }
.slot .mc-icon { width: 22px; height: 22px; }
.empty-tool-icon { font-size: 24px; line-height: 1; color: #cad7c4; }
.slot small { font-size: 9px; line-height: 1; max-width: 100%; overflow: hidden; }
.count { position: absolute; right: 3px; top: 0; font-size: 10px; text-shadow: 1px 1px #000; }
.slotnum { position: absolute; left: 3px; top: 1px; color: #d8e4d4; font-size: 8px; }
#mobileControls { position: absolute; inset: 0; pointer-events: none; }
.pad { position: absolute; bottom: 92px; left: 12px; display: grid; grid-template-columns: repeat(3, var(--ui-size, var(--btn))); grid-template-rows: repeat(3, var(--ui-size, var(--btn))); gap: 5px; pointer-events: auto; }
.pad button, .actions button { width: var(--ui-size, var(--btn)); height: var(--ui-size, var(--btn)); padding: 0; background: #152019d9; border: 1px solid #ffffff65; backdrop-filter: blur(4px); font-size: 20px; touch-action: none; opacity: var(--controls-opacity); }
.pad .up { grid-column: 2; grid-row: 1; }
.pad .left { grid-column: 1; grid-row: 2; }
.pad .crouch { grid-column: 2; grid-row: 2; font-size: 10px; }
.pad .crouch.active { background: #9b7839; outline: 2px solid #ffe08a; }
.pad .right { grid-column: 3; grid-row: 2; }
.pad .down { grid-column: 2; grid-row: 3; }
.control-button { --offset-x: 0px; --offset-y: 0px; transform: translate(var(--offset-x), var(--offset-y)); }
.control-button:active { transform: translate(var(--offset-x), var(--offset-y)) scale(.97); }
.actions { position: absolute; right: 12px; bottom: 100px; display: grid; grid-template-columns: repeat(2, var(--ui-size, var(--btn))); gap: 7px; pointer-events: auto; }
.actions button { font-size: 12px; font-weight: 900; }
.actions .jump { border-radius: 50%; background: #557e3cc9; }
.actions .mine { background: #8b553cc9; }
.actions .place { background: #3b6f51d9; }
.joystick { position: absolute; left: 14px; bottom: 100px; z-index: 2; width: calc(var(--ui-size) * 2.05); height: calc(var(--ui-size) * 2.05); border: 2px solid #ffffff65; border-radius: 50%; background: #18251c88; backdrop-filter: blur(4px); pointer-events: auto; touch-action: none; opacity: var(--controls-opacity); transform: translate(var(--offset-x, 0px), var(--offset-y, 0px)); }
.joystick-knob { position: absolute; left: 50%; top: 50%; width: var(--ui-size); height: var(--ui-size); transform: translate(-50%, -50%); border: 2px solid #ffffffa0; border-radius: 50%; background: #71945bd9; box-shadow: 0 3px 10px #0006; pointer-events: none; }
body.joystick-mode .pad { display: none; }
body.joystick-mode .joystick { display: block !important; }
#hint { position: absolute; top: 58px; left: 50%; transform: translateX(-50%); max-width: 90vw; text-align: center; background: #101a14c9; border: 1px solid #ffffff30; border-radius: 9px; padding: 6px 10px; font-size: 11px; color: #e8f2df; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#tutorialBanner { position: absolute; z-index: 3; top: 104px; left: 50%; transform: translateX(-50%); display: flex; gap: 10px; align-items: center; max-width: min(560px, 92vw); padding: 10px 12px; border: 1px solid #f1d881; border-radius: 10px; background: #302611e8; color: #fff4c5; font-size: 11px; pointer-events: auto; }
#tutorialBanner span { color: #eee1b3; }
#tutorialBanner button { padding: 2px 7px; border: 0; background: transparent; font-size: 18px; }
#inventoryPanel, #craftPanel, #pausePanel { position: absolute; inset: 0; display: grid; place-items: center; background: #0610099c; pointer-events: auto; padding: 12px; }
#inventoryPanel { touch-action: pan-y; }
.panel { width: min(560px, 100%); max-height: 88%; overflow: auto; background: #1b2a20; border: 2px solid #819775; border-radius: 15px; padding: 16px; box-shadow: 0 15px 45px #0008; touch-action: pan-y; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.panel h2 { margin: 0 0 6px; }
.panel p { font-size: 12px; color: #c2d0bf; line-height: 1.5; }
.itemgrid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; margin: 13px 0; }
.item { min-height: 58px; padding: 5px 2px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; background: #2c3d30; font-size: 10px; text-align: center; }
.item .swatch { width: 23px; height: 23px; }
.item:disabled { opacity: .35; cursor: not-allowed; }
#inventoryPanel .itemgrid, #inventoryPanel .item { touch-action: pan-y !important; }
.inventory-close-button { background: #6c2d29; border-color: #e2a29a; font-size: 16px; }
.panel-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.panel-actions button { flex: 1; }
.recipe { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px; margin: 7px 0; background: #2b3b2f; border-radius: 9px; }
.recipe div { font-size: 12px; }
.recipe button { font-size: 12px; padding: 8px; }
#toast { position: absolute; top: 22%; left: 50%; transform: translateX(-50%); background: #142019ed; border: 1px solid #ffffff35; border-radius: 10px; padding: 9px 13px; font-size: 12px; pointer-events: none; opacity: 0; transition: opacity .2s; max-width: 85%; text-align: center; }
#toast.show { opacity: 1; }
@media (orientation: portrait) { #rotateNotice { display: block; } }
#rotateNotice { display: none; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 9; background: #142019ed; border: 1px solid #ffffff40; padding: 12px 15px; border-radius: 12px; font-size: 12px; pointer-events: none; }
@media (max-width: 600px) {
  .setting { grid-template-columns: 1fr; gap: 5px; }
  #tutorialBanner { top: 102px; }
  .topline { left: 6px; right: 6px; }
}
/* No modo joystick, mantém o botão de agachar disponível ao lado do direcional. */
body.joystick-mode .pad { display: block; width: var(--ui-size); height: var(--ui-size); }
body.joystick-mode .pad button[data-move] { display: none; }
body.joystick-mode .pad .crouch { display: block; position: absolute; left: calc(var(--ui-size) * 2.1); bottom: 0; }
body.joystick-mode .pad { pointer-events: none; }
/* O botão de agachar continua independente e utilizável fora do direcional. */
body.joystick-mode .pad .crouch { pointer-events: auto; }
.joystick { width: calc(var(--ui-size) + var(--ui-size)); height: calc(var(--ui-size) + var(--ui-size)); }
.preview-actions .preview-crouch { display: none; }
.control-preview.joystick-mode .preview-actions .preview-crouch { display: grid; grid-column: 1 / -1; width: 88px; justify-self: end; }

/* Interface de computador: mouse/teclado em vez de controles táteis sobre o mundo. */
@media (min-width: 900px) and (hover: hover) and (pointer: fine) {
  #mobileControls { display: none !important; }
  #menu { padding: clamp(24px, 4vw, 56px); }
  .menu-card { width: min(760px, 100%); padding: clamp(28px, 3vw, 40px); }
  .brand h1 { font-size: clamp(38px, 4vw, 52px); }
  .topline { left: 22px; right: 22px; top: 18px; align-items: center; }
  .pill { padding: 10px 14px; font-size: 14px; }
  .topline button { padding: 10px 14px; }
  #hint { top: 76px; max-width: min(78vw, 980px); font-size: 13px; }
  #hotbar { bottom: 18px; gap: 6px; padding: 8px; }
  .slot { width: 62px; height: 66px; }
  .slot .mc-icon { width: 27px; height: 27px; }
  #survivalBars { bottom: 112px; gap: 4px; }
  #healthBar, #hungerBar { font-size: 22px; }
  .panel { width: min(720px, 100%); padding: 22px; }
  .itemgrid { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
}
