[hidden] { display: none !important; }
@font-face { font-family: "Press Start 2P"; src: url("fonts/PressStart2P-Regular.ttf") format("truetype"); font-display: block; }
:root {
  --inset-top: var(--discord-safe-area-inset-top, 0px);
  --inset-right: var(--discord-safe-area-inset-right, 0px);
  --inset-bottom: var(--discord-safe-area-inset-bottom, 0px);
  --inset-left: var(--discord-safe-area-inset-left, 0px);
  --ink: #283038;
  --paper: #f8f8f0;
}
html, body { margin: 0; height: 100%; background: #101018; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
body { font: 16px/1.4 system-ui, sans-serif; }
#game { position: absolute; inset: var(--inset-top) var(--inset-right) var(--inset-bottom) var(--inset-left); }
#game canvas { image-rendering: pixelated; image-rendering: crisp-edges; }

#hud { position: absolute; top: calc(8px + var(--inset-top)); left: calc(8px + var(--inset-left)); right: calc(8px + var(--inset-right)); display: flex; justify-content: space-between; align-items: flex-start; pointer-events: none; }
#place-name { background: var(--paper); color: var(--ink); border: 3px solid var(--ink); border-radius: 6px; padding: 4px 10px; font-weight: 700; opacity: 0; transition: opacity .4s; }
#place-name.shown { opacity: 1; }
.hud-buttons { display: flex; gap: 8px; }
#open-menu { pointer-events: auto; width: 44px; height: 44px; border-radius: 50%; border: 3px solid var(--ink); background: var(--paper); color: var(--ink); font-size: 20px; line-height: 1; }
#toggle-pad { pointer-events: auto; width: 44px; height: 44px; border-radius: 50%; border: 3px solid var(--ink); background: var(--paper); color: var(--ink); font-size: 22px; line-height: 1; }

#pad { position: absolute; left: calc(12px + var(--inset-left)); right: calc(12px + var(--inset-right)); bottom: calc(12px + var(--inset-bottom)); display: flex; justify-content: space-between; align-items: flex-end; pointer-events: none; }
#pad button { pointer-events: auto; border: 3px solid var(--ink); background: rgba(248, 248, 240, .85); color: var(--ink); font-size: 22px; font-weight: 700; }
#pad button.held { background: #c8d0e0; }
.dpad { display: grid; grid-template-columns: 56px 56px 56px; grid-template-rows: 56px 56px 56px; }
.dpad [data-dir] { width: 56px; height: 56px; }
.dpad [data-dir="north"] { grid-column: 2; grid-row: 1; border-radius: 10px 10px 0 0; }
.dpad [data-dir="west"] { grid-column: 1; grid-row: 2; border-radius: 10px 0 0 10px; }
.dpad [data-dir="east"] { grid-column: 3; grid-row: 2; border-radius: 0 10px 10px 0; }
.dpad [data-dir="south"] { grid-column: 2; grid-row: 3; border-radius: 0 0 10px 10px; }
.buttons { display: flex; gap: 16px; align-items: flex-end; }
.buttons button { width: 68px; height: 68px; border-radius: 50%; }
.buttons [data-button="a"] { margin-bottom: 36px; }

#textbox { position: absolute; left: calc(12px + var(--inset-left)); right: calc(12px + var(--inset-right)); bottom: calc(12px + var(--inset-bottom)); max-width: 640px; margin: 0 auto; background: var(--paper); color: var(--ink); border: 4px solid var(--ink); border-radius: 8px; padding: 12px 16px; min-height: 3.2em; box-shadow: inset 0 0 0 3px #a8b8d0; font-size: 18px; }
#textbox p { margin: 0; white-space: pre-wrap; }
#textbox .more { position: absolute; right: 12px; bottom: 6px; animation: bob 0.8s infinite; }
@keyframes bob { 50% { transform: translateY(3px); } }
body.pad-on #textbox { bottom: calc(196px + var(--inset-bottom)); }

#notice { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 24px; color: #f8f8f8; font: 16px/1.5 system-ui, sans-serif; text-align: center; background: #101018; }

#battle-menu {
  position: absolute; left: calc(12px + var(--inset-left)); right: calc(12px + var(--inset-right)); bottom: calc(12px + var(--inset-bottom));
  max-width: 640px; margin: 0 auto; display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
#battle-menu button {
  min-height: 56px; border: 3px solid var(--ink); border-radius: 8px; background: var(--paper); color: var(--ink);
  font: 13px/1.3 "Press Start 2P", monospace; text-align: left; padding: 8px 12px; display: flex; flex-direction: column; justify-content: center; gap: 6px;
}
#battle-menu button:disabled { opacity: .45; }
#battle-menu button .detail { font-size: 10px; opacity: .8; display: flex; justify-content: space-between; gap: 8px; }
#battle-menu button.wide { grid-column: 1 / -1; }
#battle-menu button.back { background: #d8d8e0; }
#battle-menu .type { border-radius: 4px; padding: 2px 4px; color: #fff; text-transform: uppercase; }
#battle-menu.command { grid-template-columns: 1fr 0.8fr 1fr; grid-template-areas: "fight fight fight" "bag run party"; }
#battle-menu.command button { align-items: center; text-align: center; color: #fff; text-shadow: 2px 2px 0 rgba(0, 0, 0, .35); border-radius: 14px; box-shadow: inset 0 3px 0 rgba(255, 255, 255, .35), inset 0 -4px 0 rgba(0, 0, 0, .18); }
#battle-menu.command .fight { grid-area: fight; min-height: 84px; font-size: 18px; background: linear-gradient(#f06a5a, #d0403a); }
#battle-menu.command .bag { grid-area: bag; background: linear-gradient(#f8c050, #e09428); }
#battle-menu.command .run { grid-area: run; background: linear-gradient(#6aa8f0, #3e78d0); }
#battle-menu.command .party { grid-area: party; background: linear-gradient(#78cc68, #449a44); }
#battle-menu button.tinted { background: linear-gradient(color-mix(in srgb, var(--tint) 30%, #fff), color-mix(in srgb, var(--tint) 55%, #fff)); border-left-width: 10px; border-left-color: var(--tint); }
body.in-battle { background: repeating-linear-gradient(135deg, #2a3644 0 12px, #26313e 12px 24px); }
body.in-battle #pad, body.in-battle #toggle-pad, body.in-battle #open-menu { display: none; }
body.in-battle #textbox { top: calc(var(--scene-bottom, 0px) + 10px + var(--inset-top)); bottom: auto; height: 76px; box-sizing: border-box; overflow: hidden; }
body.in-battle #battle-menu { top: calc(var(--scene-bottom, 0px) + 96px + var(--inset-top)); bottom: auto; }

#sheet {
  position: absolute; left: calc(8px + var(--inset-left)); right: calc(8px + var(--inset-right)); bottom: calc(8px + var(--inset-bottom));
  max-width: 560px; max-height: calc(100% - 80px - var(--inset-top) - var(--inset-bottom)); margin: 0 auto; overflow-y: auto;
  background: var(--paper); color: var(--ink); border: 4px solid var(--ink); border-radius: 10px; box-shadow: inset 0 0 0 3px #a8b8d0;
  padding: 12px; box-sizing: border-box; font: 15px/1.35 system-ui, sans-serif;
}
#sheet header { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
#sheet h2 { margin: 0; font: 13px/1.3 "Press Start 2P", monospace; }
#sheet .close { width: 40px; height: 40px; border: 3px solid var(--ink); border-radius: 50%; background: #d8d8e0; font-size: 16px; color: var(--ink); }
#sheet .note { margin: 8px 0; min-height: 1.2em; }
#sheet .note:empty { display: none; }
#sheet h3 { margin: 12px 0 6px; font: 11px/1.3 "Press Start 2P", monospace; }
#sheet .row {
  width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 52px; margin: 6px 0; padding: 8px 12px;
  border: 3px solid var(--ink); border-radius: 8px; background: #fff; color: var(--ink); text-align: left; font: inherit;
}
#sheet .row:disabled { opacity: .45; }
#sheet .row.info { background: transparent; border-style: dashed; border-width: 2px; box-sizing: border-box; }
#sheet .row .name { font-weight: 700; }
#sheet .row .small { font-size: 13px; opacity: .75; display: block; }
#sheet .row .right { text-align: right; white-space: nowrap; }
#sheet .picker { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 12px 0; }
#sheet .picker button { width: 52px; height: 52px; border: 3px solid var(--ink); border-radius: 8px; background: #fff; font-size: 22px; color: var(--ink); }
#sheet .picker output { min-width: 48px; text-align: center; font: 16px "Press Start 2P", monospace; }
#sheet .go { width: 100%; min-height: 52px; border: 3px solid var(--ink); border-radius: 8px; background: #58a8f8; color: #fff; font-weight: 700; font-size: 16px; }
body.sheet-open #pad, body.sheet-open #toggle-pad, body.sheet-open #open-menu { display: none; }
#sheet img.picture { display: block; width: 100%; max-width: 480px; margin: 8px auto; image-rendering: pixelated; border-radius: 6px; }
#sheet .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 6px; margin: 8px 0; }
#sheet .grid button { position: relative; aspect-ratio: 1; border: 2px solid var(--ink); border-radius: 8px; background: #fff; padding: 0; overflow: hidden; }
#sheet .grid button:disabled { background: #e8e8e0; opacity: 1; }
#sheet .grid .number { position: absolute; top: 2px; left: 4px; font: 9px "Press Start 2P", monospace; color: var(--ink); }
#sheet .grid img { width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; }
#sheet .grid img.dim { filter: brightness(0); opacity: .6; }
#sheet .grid .unknown { font: 16px "Press Start 2P", monospace; color: #a0a0a8; }
#sheet .choices { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 8px 0; }
#sheet .choices button { min-height: 48px; border: 3px solid var(--ink); border-radius: 8px; background: #fff; color: var(--ink); font: inherit; }
#sheet .choices button.on { background: #58a8f8; color: #fff; }
