/* Thistlemere — illustrated point-and-click shell. All styles local/offline.
   The game remains logically 320×200; JS chooses an integer CSS scale. */

:root {
  --ink: #09080d;
  --night: #121019;
  --walnut-1: #1b120f;
  --walnut-2: #2c1d18;
  --walnut-3: #493024;
  --brass-dark: #6b542d;
  --brass: #b69752;
  --brass-light: #e0c67d;
  --parchment: #d8c696;
  --parchment-dark: #8d7545;
  --text: #e8ddc2;
  --dim: #9f958c;
  --amber: #f1bd55;
  --canvas-w: 960px;
  --canvas-h: 600px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

html,
body {
  min-width: 100%;
  min-height: 100%;
  background:
    radial-gradient(circle at 50% 0, #211b2a 0, var(--night) 42%, var(--ink) 100%);
  color: var(--text);
  font-family: "Courier New", ui-monospace, monospace;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}

body { overflow: hidden; }

button,
a,
input { -webkit-tap-highlight-color: transparent; }

#verbs button,
#inv button,
#btn-sound,
header a.back {
  touch-action: manipulation;
  user-select: none;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 2px solid var(--brass-light);
  outline-offset: 3px;
}

#app {
  width: min(100%, 1180px);
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  padding: 4px 8px;
  display: grid;
  grid-template-rows: 20px minmax(0, 1fr) 82px;
  gap: 4px;
}

header {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--dim);
  font-size: 11px;
  text-shadow: 1px 1px 0 #000;
}

header .game-title {
  color: var(--text);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
}

header .spacer { flex: 1; }
header a.back { color: var(--dim); text-decoration: none; }
header a.back:hover { color: var(--text); }

#score {
  color: var(--amber);
  font-size: 11px;
  transition: color 140ms ease, transform 140ms ease;
}

#score.pulse { color: #fff0ad; transform: scale(1.08); }

#btn-sound {
  min-height: 20px;
  padding: 1px 8px;
  border: 1px solid #3d3347;
  background: #16121c;
  color: var(--dim);
  font: inherit;
  font-size: 10px;
  cursor: pointer;
}

/* --------------------------------------------------------------- stage */
#stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #050509;
  border: 1px solid #2f2737;
  box-shadow:
    0 0 0 1px #08070b,
    0 8px 24px rgba(0, 0, 0, .38);
}

#stage::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  box-shadow: inset 0 0 28px rgba(2, 2, 5, .42);
}

#screen {
  display: block;
  width: var(--canvas-w);
  height: var(--canvas-h);
  max-width: 100%;
  max-height: 100%;
  background: #000;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  touch-action: manipulation;
  cursor: crosshair;
}

#screen[data-cursor="walk"] { cursor: crosshair; }
#screen[data-cursor="look"] { cursor: zoom-in; }
#screen[data-cursor="use"]  { cursor: grab; }
#screen[data-cursor="talk"] { cursor: help; }
#screen[data-cursor="item"] { cursor: cell; }

#scene-label {
  position: absolute;
  top: 10px;
  left: 12px;
  z-index: 3;
  padding: 4px 9px 3px;
  border: 1px solid rgba(224, 198, 125, .62);
  background: rgba(10, 8, 12, .72);
  color: var(--parchment);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
}

#scene-label.show {
  animation: scene-label 2.2s ease both;
}

@keyframes scene-label {
  0% { opacity: 0; transform: translateY(-4px); }
  12%, 72% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; }
}

#stage.scene-enter #screen { animation: scene-enter 220ms ease-out both; }
@keyframes scene-enter { from { opacity: .25; } to { opacity: 1; } }

/* Classic message window: text remains DOM-native and accessible. */
#textbox {
  position: absolute;
  left: 50%;
  bottom: 7%;
  z-index: 4;
  width: min(78%, 650px);
  transform: translateX(-50%);
  padding: 13px 18px 9px;
  border: 2px solid var(--brass);
  outline: 2px solid rgba(20, 12, 9, .9);
  background:
    linear-gradient(rgba(239, 225, 185, .97), rgba(206, 184, 132, .97));
  color: #24190f;
  box-shadow:
    0 0 0 2px rgba(225, 199, 122, .32),
    0 8px 0 rgba(0, 0, 0, .45),
    0 16px 32px rgba(0, 0, 0, .35);
  cursor: pointer;
  user-select: none;
}

#textbox .tb-speaker {
  margin-bottom: 4px;
  color: #6f451f;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

#textbox .tb-text {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 15px;
  line-height: 1.42;
  text-shadow: 0 1px rgba(255, 255, 255, .35);
}

#textbox .tb-more {
  height: 10px;
  margin-top: 2px;
  text-align: right;
  font-size: 9px;
  opacity: .58;
  animation: bob 900ms steps(2, end) infinite;
}

@keyframes bob { 50% { transform: translateY(2px); } }

/* --------------------------------------------------------- command deck */
#bar {
  position: relative;
  min-width: 0;
  height: 82px;
  display: flex;
  gap: 7px;
  padding: 5px;
  border: 2px solid var(--brass-dark);
  outline: 1px solid #080608;
  background:
    repeating-linear-gradient(90deg, rgba(255,255,255,.025) 0 1px, transparent 1px 12px),
    linear-gradient(#34231d, #17100f 54%, #261713);
  box-shadow:
    inset 0 1px 0 rgba(239, 207, 128, .35),
    inset 0 -2px 0 rgba(0, 0, 0, .55),
    0 -3px 14px rgba(0, 0, 0, .25);
}

#bar::before {
  content: "";
  position: absolute;
  inset: 3px;
  z-index: 2;
  border: 1px solid rgba(224, 198, 125, .18);
  box-shadow: inset 0 0 0 1px rgba(8, 6, 8, .78);
  pointer-events: none;
}

#bar > * { position: relative; z-index: 1; }

#verbs {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(4, 66px);
  gap: 5px;
}

#verbs button {
  position: relative;
  min-width: 0;
  height: 68px;
  padding: 4px 4px 5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: 1px solid #6c542e;
  background: linear-gradient(#2c2020, #121015);
  color: #b7aa91;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .8px;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow:
    inset 0 0 0 2px #120d0e,
    inset 0 1px 0 rgba(230, 199, 120, .14);
}

#verbs button::after {
  content: "";
  position: absolute;
  inset: 2px;
  border: 1px solid rgba(224, 198, 125, .12);
  pointer-events: none;
}

#verbs button:hover { color: #e1d1aa; border-color: #967946; }

#verbs button:active {
  transform: translateY(1px);
  color: #ffe6ad;
  box-shadow:
    inset 0 0 8px rgba(0, 0, 0, .72),
    inset 0 0 0 2px #120d0e;
}

#verbs button.active {
  border-color: var(--brass-light);
  color: #ffe19a;
  background: linear-gradient(#463224, #1e1616);
  box-shadow:
    inset 0 0 0 2px #171012,
    0 0 8px rgba(241, 189, 85, .22);
}

.verb-icon {
  width: 29px;
  height: 29px;
  fill: currentColor;
  filter: drop-shadow(1px 1px 0 #000);
}

.verb-icon .icon-cut { fill: #171217; }
#verbs button.active .verb-icon .icon-cut { fill: #2a1d19; }

#command-deck {
  min-width: 0;
  flex: 1;
  display: grid;
  grid-template-rows: 27px minmax(0, 1fr);
  gap: 4px;
}

#commandline {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: .55em;
  overflow: hidden;
  padding: 3px 11px;
  border: 1px solid #4d3926;
  background: #100e13;
  color: var(--amber);
  font-size: 14px;
  line-height: 1;
  letter-spacing: .2px;
  white-space: nowrap;
  text-overflow: ellipsis;
  box-shadow: inset 0 0 8px rgba(0,0,0,.65);
}

#command-target { color: #f3e4bd; overflow: hidden; text-overflow: ellipsis; }

#inv {
  min-width: 0;
  display: flex;
  align-items: stretch;
  gap: 5px;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--brass-dark) #120e12;
}

#inv button,
#inv .inv-slot {
  flex: 0 0 43px;
  width: 43px;
  min-height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid #574127;
  background: linear-gradient(#151218, #09080c);
  box-shadow:
    inset 0 0 8px rgba(0,0,0,.8),
    inset 0 1px 0 rgba(217, 188, 112, .09);
}

#inv button { cursor: pointer; }
#inv button:hover { border-color: #9b7941; }
#inv button:active { transform: translateY(1px); box-shadow: inset 0 2px 9px #000; }
#inv button.active {
  border-color: var(--brass-light);
  background: #241a18;
  box-shadow: inset 0 0 10px rgba(241,189,85,.12), 0 0 6px rgba(241,189,85,.2);
}

#inv canvas {
  width: 34px;
  height: 34px;
  image-rendering: pixelated;
}

/* ------------------------------------------------------------- overlays */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  text-align: center;
}

#title-overlay {
  justify-content: flex-end;
  padding-right: clamp(28px, 8vw, 140px);
  background-color: #10131a;
  background-image: url("cover.png?v=2.2.0");
  background-position: center;
  background-size: cover;
}

.title-panel {
  width: min(48vw, 610px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 24px;
  color: var(--text);
  text-shadow: 2px 2px 0 #050407, 0 0 12px rgba(0,0,0,.9);
}

.title-panel h1,
.pause-panel h1 {
  color: #f3d281;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(30px, 4vw, 56px);
  letter-spacing: clamp(4px, .65vw, 10px);
  text-transform: uppercase;
  text-shadow: 2px 3px 0 #17100c, 0 0 18px rgba(0,0,0,.95);
}

.overlay .sub {
  max-width: 46ch;
  color: #ddd1b9;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 15px;
  line-height: 1.5;
}

.title-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.overlay button {
  min-width: 150px;
  min-height: 43px;
  padding: 9px 22px;
  border: 2px solid #d6b565;
  background: linear-gradient(#e1c778, #aa8140);
  color: #21150e;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  text-shadow: 0 1px rgba(255,255,255,.4);
  cursor: pointer;
  box-shadow: inset 0 0 0 2px rgba(59,38,20,.35), 0 5px 0 rgba(20,12,8,.72);
}

.overlay button:hover { filter: brightness(1.1); }
.overlay button:active { transform: translateY(2px); box-shadow: inset 0 0 0 2px rgba(59,38,20,.35), 0 3px 0 rgba(20,12,8,.72); }

.overlay button.secondary {
  border-color: #927a51;
  background: linear-gradient(#3b302a, #1c1718);
  color: #e7d6ae;
  text-shadow: 1px 1px #000;
}

.overlay button.quiet {
  border-color: #51453a;
  background: #171318;
  color: #a99f91;
  box-shadow: inset 0 0 0 1px #08070a, 0 3px 0 rgba(0,0,0,.6);
}

.overlay label {
  color: #c4b9a4;
  font-size: 11px;
  text-shadow: 1px 1px #000;
}

.overlay .hint {
  color: #b8ac99;
  font-size: 10px;
  opacity: .82;
  text-shadow: 1px 1px #000;
}

.hint-touch { display: none; }

#pause-overlay {
  background: rgba(7, 6, 10, .9);
  backdrop-filter: blur(2px);
}

.pause-panel {
  width: min(92vw, 420px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 28px 30px;
  border: 2px solid var(--brass-dark);
  background: linear-gradient(#2c201d, #120f14);
  box-shadow: 0 18px 60px rgba(0,0,0,.6), inset 0 0 0 2px #09070a;
}

.pause-panel h1 { font-size: 29px; }

/* ---------------------------------------------------------- responsiveness */
@media (max-width: 820px) {
  #app {
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 3px;
    grid-template-rows: 20px auto auto;
    align-content: start;
    gap: 3px;
    overflow-y: auto;
  }

  body { overflow: auto; }
  #stage { aspect-ratio: 8 / 5; }
  #screen { width: 100%; height: auto; max-height: none; }

  #bar {
    height: auto;
    min-height: 116px;
    flex-direction: column;
  }

  #verbs { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  #verbs button { width: auto; height: 52px; flex-direction: row; gap: 5px; font-size: 8px; }
  .verb-icon { width: 24px; height: 24px; }
  #command-deck { grid-template-rows: 25px 42px; }
  #commandline { font-size: 12px; }
  #textbox { width: 88%; bottom: 4%; padding: 10px 12px 6px; }
  #textbox .tb-text { font-size: 13px; }

  #title-overlay {
    justify-content: center;
    padding: 20px;
    background-position: 42% center;
  }

  .title-panel {
    width: min(94vw, 520px);
    padding: 18px;
    background: rgba(8, 8, 12, .48);
    box-shadow: 0 0 40px rgba(0,0,0,.35);
  }
}

@media (max-width: 520px) {
  header { gap: 7px; font-size: 9px; }
  header .game-title { font-size: 10px; letter-spacing: 1.5px; }
  #score { font-size: 9px; }
  #btn-sound { padding-inline: 5px; font-size: 9px; }
  #verbs button { flex-direction: column; height: 52px; gap: 0; }
  .verb-icon { width: 21px; height: 21px; }
  #inv button, #inv .inv-slot { flex-basis: 40px; width: 40px; }
  .title-actions { flex-direction: column; }
  .overlay button { min-width: 178px; }
}

/* Portrait phones use the whole dynamic viewport as an adventure cabinet.
   The 8:5 scene never stretches; the command console absorbs the extra
   height and turns it into an intentional inventory/story well. */
@media (max-width: 820px) and (orientation: portrait) {
  body { overflow: hidden; }

  #app {
    width: 100%;
    height: 100vh;
    height: 100svh;
    height: 100dvh;
    min-height: 0;
    padding: 3px;
    padding-bottom: max(3px, env(safe-area-inset-bottom));
    grid-template-rows: 32px auto minmax(0, 1fr);
    align-content: stretch;
    gap: 3px;
    overflow: hidden;
  }

  header {
    min-height: 32px;
    gap: 6px;
    padding: 0 4px;
    border: 1px solid #3d2a20;
    background:
      repeating-linear-gradient(90deg, rgba(255,255,255,.018) 0 1px, transparent 1px 9px),
      linear-gradient(#271a18, #120e13);
    box-shadow: inset 0 1px 0 rgba(224,198,125,.14), inset 0 -1px #080608;
  }

  header a.back {
    min-width: 44px;
    height: 30px;
    display: inline-flex;
    align-items: center;
  }

  header .game-title {
    font-size: 11px;
    letter-spacing: 1.8px;
    color: #f0dfb6;
  }

  #score { flex: 0 0 auto; font-size: 10px; white-space: nowrap; }

  #btn-sound {
    flex: 0 0 auto;
    min-width: 62px;
    height: 30px;
    padding: 0 6px;
    border-color: #5b432a;
    background: linear-gradient(#261b19, #100d12);
    color: #c8b992;
    font-size: 9px;
  }

  #stage {
    width: 100%;
    min-height: 0;
    aspect-ratio: 8 / 5;
    border-color: #6b542d;
    box-shadow: 0 0 0 1px #080608, 0 5px 14px rgba(0,0,0,.45);
  }

  #bar {
    min-height: 0;
    height: auto;
    padding: 6px;
    display: grid;
    grid-template-rows: 64px minmax(0, 1fr);
    gap: 6px;
    overflow: hidden;
    border-color: #8b6a36;
    background:
      repeating-linear-gradient(92deg, rgba(255,255,255,.022) 0 1px, transparent 1px 14px),
      radial-gradient(ellipse at 50% 18%, rgba(98,57,39,.32), transparent 58%),
      linear-gradient(90deg, #140d0d, #2b1718 50%, #140d0d);
    box-shadow:
      inset 0 1px 0 rgba(239,207,128,.34),
      inset 0 -3px 0 rgba(0,0,0,.72),
      0 -2px 9px rgba(0,0,0,.28);
  }

  #verbs {
    width: 100%;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
  }

  #verbs button {
    width: auto;
    height: 64px;
    min-height: 44px;
    padding: 5px 3px 6px;
    flex-direction: column;
    gap: 2px;
    border-color: #806238;
    font-size: 10px;
    letter-spacing: .65px;
    background: linear-gradient(#30201d, #110e13 72%);
    box-shadow:
      inset 0 0 0 2px #100b0d,
      inset 0 1px 0 rgba(239,207,128,.22),
      inset 1px 0 0 rgba(181,141,75,.12);
  }

  #verbs button.active {
    color: #ffe1a0;
    background: linear-gradient(#523520, #211416 76%);
    box-shadow:
      inset 0 0 0 2px #160e10,
      inset 0 0 9px rgba(241,189,85,.14),
      0 0 7px rgba(241,189,85,.18);
  }

  .verb-icon { width: 29px; height: 29px; }

  #command-deck {
    min-height: 0;
    display: grid;
    grid-template-rows: 36px 62px minmax(0, 1fr);
    gap: 6px;
  }

  #commandline {
    min-height: 36px;
    padding: 5px 12px;
    border-color: #70522f;
    font-size: 15px;
    box-shadow:
      inset 0 0 10px rgba(0,0,0,.76),
      inset 0 1px 0 rgba(224,198,125,.08);
  }

  #inv {
    min-height: 0;
    gap: 5px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
  }

  #inv button,
  #inv .inv-slot {
    flex: 0 0 calc((100% - 25px) / 6);
    width: auto;
    min-width: 44px;
    min-height: 56px;
    aspect-ratio: 1;
    border-color: #765833;
    box-shadow:
      inset 0 0 12px rgba(0,0,0,.88),
      inset 0 1px 0 rgba(224,198,125,.14),
      0 1px 0 rgba(172,126,61,.08);
  }

  #inv canvas { width: 46px; height: 46px; }

  #command-deck::after {
    content: "";
    min-height: 0;
    border: 1px solid rgba(107,84,45,.66);
    background-color: #110a10;
    background-image:
      linear-gradient(rgba(17,10,16,.16), rgba(17,10,16,.56)),
      url("assets/art/thistle-cabinet-v2.2.png?v=2.2.0");
    background-repeat: no-repeat;
    background-position: center, center 62%;
    background-size: 100% 100%, min(62%, 260px) auto;
    box-shadow:
      inset 0 0 0 2px #090608,
      inset 0 0 34px rgba(0,0,0,.76),
      inset 0 1px 0 rgba(224,198,125,.1);
    opacity: .86;
    image-rendering: pixelated;
  }

  #textbox {
    width: 92%;
    bottom: 4%;
    padding: 11px 13px 7px;
  }

  #textbox .tb-text { font-size: 15px; line-height: 1.36; }

  .hint-pointer { display: none; }
  .hint-touch { display: inline; }
}

@media (max-width: 360px) and (orientation: portrait) {
  header { gap: 4px; }
  header a.back {
    min-width: 32px;
    justify-content: center;
    font-size: 0;
  }
  header a.back::before { content: "←"; font-size: 15px; }
  header .game-title { font-size: 10px; letter-spacing: 1.2px; }
  #score { font-size: 9px; }
}

@media (max-height: 520px) and (orientation: landscape) {
  #app { grid-template-rows: 18px minmax(0, 1fr) 62px; }
  #bar { height: 62px; padding: 3px; }
  #verbs { grid-template-columns: repeat(4, 50px); gap: 3px; }
  #verbs button { height: 52px; font-size: 7px; padding: 2px; }
  .verb-icon { width: 21px; height: 21px; }
  #command-deck { grid-template-rows: 22px minmax(0, 1fr); gap: 2px; }
  #commandline { font-size: 11px; padding-block: 2px; }
  #inv button, #inv .inv-slot { flex-basis: 34px; width: 34px; min-height: 31px; }
  #inv canvas { width: 29px; height: 29px; }
  #textbox { bottom: 4%; padding: 8px 11px 4px; }
  #textbox .tb-text { font-size: 12px; }
}

html.rm *,
html.rm *::before,
html.rm *::after {
  scroll-behavior: auto !important;
  animation-duration: .001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: .001ms !important;
}
