:root {
  --ink: #f7fbff;
  --ink-dark: #14212b;
  --muted: #c6d3dc;
  --panel: rgba(14, 28, 39, .9);
  --line: rgba(255, 255, 255, .2);
  --tile: #fbfcff;
  --tile-ink: #102331;
  --accent: #35c2d1;
  --gold: #f0b84c;
  --green: #57d586;
  --red: #ff6d68;
  --shadow: 0 18px 54px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

[hidden] { display: none !important; }

body {
  margin: 0;
  background: #07121b;
  color: var(--ink);
  font-family: "Segoe UI", Arial, sans-serif;
}

button {
  border: 0;
  font: inherit;
  cursor: pointer;
}

button:focus-visible,
.word-tile:focus-visible,
.assembly-area:focus-visible {
  outline: 4px solid var(--gold);
  outline-offset: 3px;
}

.page-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 12px;
}

.game-frame {
  position: relative;
  width: min(100%, 1360px);
  min-height: min(760px, calc(100vh - 24px));
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 8px;
  background: #152937;
  box-shadow: var(--shadow);
}

.scene-layer,
.scene-image,
.scene-fallback {
  position: absolute;
  inset: 0;
}

.scene-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scene-image.missing { display: none; }

.scene-fallback {
  background: linear-gradient(180deg, rgba(67, 134, 158, .9), rgba(7, 18, 27, .96));
}

.level-2 .scene-fallback { background: linear-gradient(180deg, #385c54, #0a1f1e); }
.level-3 .scene-fallback { background: linear-gradient(180deg, #20243d, #7b2e4b); }
.level-4 .scene-fallback { background: linear-gradient(180deg, #bd7b3f, #493b2f); }
.level-5 .scene-fallback { background: linear-gradient(180deg, #17869b, #08223e); }

.top-bar,
.intro-panel,
.play-layout,
.transition-panel,
.game-over-panel,
.control-bar {
  position: relative;
  z-index: 1;
}

.top-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 16px 20px 10px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--gold);
  font-size: .78rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1, h2, p { overflow-wrap: anywhere; }

h1 {
  margin: 0;
  font-size: clamp(1.7rem, 3vw, 3.2rem);
  line-height: 1;
}

h2 {
  margin: 0;
  font-size: clamp(1.35rem, 2vw, 2rem);
}

.status-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  max-width: 640px;
}

.status-strip span,
.progress-line span:not(.meter),
.small-tool {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(8, 20, 30, .66);
  color: var(--ink);
  font-weight: 800;
  font-size: .86rem;
}

.small-tool {
  color: var(--ink);
}

.lives-label {
  color: #ff7f8b !important;
  font-size: 1rem !important;
  letter-spacing: 2px;
}

.level-jump-label,
.timer-label {
  color: var(--ink);
  font-size: .85rem;
  font-weight: 900;
}

.level-jump,
.timer-select {
  min-height: 34px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,.94);
  color: var(--ink-dark);
  font: inherit;
  font-weight: 900;
}

.timer-display {
  min-width: 86px;
  justify-content: center;
}

.timer-display.warning {
  color: #ffdb70 !important;
  border-color: rgba(240, 184, 76, .7) !important;
}

.intro-panel,
.transition-panel,
.game-over-panel {
  position: relative;
  width: calc(100% - 40px);
  min-height: 560px;
  margin: 10px auto 20px;
  display: grid;
  grid-template-columns: minmax(420px, 1fr) minmax(360px, .8fr);
  gap: 24px;
  align-items: stretch;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.brand-logo {
  position: absolute;
  right: 12px;
  bottom: 8px;
  width: min(28vw, 230px);
  max-height: 26px;
  object-fit: contain;
  opacity: .58;
  pointer-events: none;
}

.transition-panel:not(.final-complete) .final-logo {
  display: none;
}

.character-pair {
  position: relative;
  min-height: 500px;
  border-radius: 8px;
  overflow: hidden;
}

.intro-tiles {
  position: absolute;
  left: 50%;
  top: 52%;
  width: 62%;
  max-height: 360px;
  object-fit: contain;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 18px 28px rgba(0, 0, 0, .34));
}

.character {
  max-width: 50%;
  max-height: 460px;
  object-fit: contain;
}

.character.missing { display: none; }

.character-pair .alex {
  position: absolute;
  left: 0;
  bottom: 0;
}

.character-pair .cipher {
  position: absolute;
  right: 0;
  bottom: 0;
}

.intro-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  padding-bottom: 6px;
}

.intro-copy p,
.transition-panel p,
.game-over-panel p {
  color: var(--muted);
  line-height: 1.45;
}

.intro-actions,
.control-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.menu-setting {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px 0 12px;
}

.menu-setting select {
  flex: 1 1 260px;
}

.intro-actions {
  margin-top: 22px;
}

.intro-actions button,
.intro-actions .tpt-link,
.control-bar button,
.transition-panel button,
.game-over-panel button,
.small-tool {
  min-height: 44px;
  padding: 0 14px;
  border-radius: 8px;
  background: rgba(255,255,255,.92);
  color: var(--ink-dark);
  font-weight: 900;
}

.intro-actions .tpt-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 1 1 100%;
  min-width: min(360px, 100%);
  background: #ffe08a;
  color: #1a1404;
  text-decoration: none;
  box-shadow: 0 0 0 3px rgba(255, 224, 138, .18);
}

.intro-actions .tpt-link:hover,
.intro-actions .tpt-link:focus-visible {
  background: #fff0b8;
}

.primary,
.control-bar .primary {
  background: var(--accent);
  color: #06151d;
}

.play-button {
  flex: 1 1 100%;
  min-width: min(360px, 100%);
  min-height: 66px !important;
  font-size: 1.35rem;
  box-shadow: 0 0 0 4px rgba(53, 194, 209, .18), 0 14px 30px rgba(0, 0, 0, .3);
}

.play-layout {
  width: calc(100% - 40px);
  margin: 10px auto 0;
}

.decoder-card {
  display: grid;
  grid-template-rows: auto auto minmax(150px, 1fr) minmax(110px, .7fr) auto;
  gap: 12px;
  min-height: 520px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.progress-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.sentence-display {
  min-height: 64px;
  padding: 14px 16px;
  border-radius: 8px;
  background: rgba(4, 12, 18, .74);
  border: 1px solid var(--line);
  color: #fff;
  font-size: clamp(1.15rem, 1.7vw, 1.65rem);
  font-weight: 800;
  line-height: 1.35;
}

.sentence-display.correct {
  box-shadow: 0 0 0 3px rgba(87, 213, 134, .55), 0 0 28px rgba(87, 213, 134, .5);
}

.assembly-area,
.word-bank {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  align-content: flex-start;
  width: 100%;
  min-width: 0;
  padding: 12px;
  border: 2px dashed rgba(255,255,255,.35);
  border-radius: 8px;
  background: rgba(255,255,255,.09);
  overflow-y: auto;
}

.word-bank {
  border-style: solid;
}

.word-tile {
  min-height: 52px;
  max-width: 100%;
  padding: 10px 16px;
  border: 2px solid rgba(12, 35, 48, .22);
  border-radius: 8px;
  background: var(--tile);
  color: var(--tile-ink);
  font-size: clamp(1.08rem, 1.45vw, 1.38rem);
  font-weight: 900;
  box-shadow: 0 4px 12px rgba(0,0,0,.2);
  touch-action: none;
}

.word-tile.dragging { opacity: .45; }
.word-tile.selected { outline: 4px solid var(--gold); outline-offset: 2px; }
.word-tile.hint { box-shadow: 0 0 0 4px rgba(240, 184, 76, .75), 0 0 18px rgba(240,184,76,.7); }

.feedback-row {
  display: grid;
  grid-template-columns: 92px 1fr 92px;
  gap: 12px;
  align-items: end;
  min-height: 92px;
}

.feedback-row .character {
  width: 92px;
  height: 92px;
  max-width: 92px;
  max-height: 92px;
  object-fit: contain;
}

.feedback {
  min-height: 54px;
  margin: 0;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(4, 12, 18, .74);
  color: var(--muted);
  font-size: clamp(1rem, 1.35vw, 1.24rem);
  font-weight: 900;
}

.feedback.good { color: var(--green); }
.feedback.bad { color: var(--red); }

.meter {
  width: min(180px, 100%);
  height: 12px;
  margin: 0;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255,255,255,.16);
}

#meter-fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  transition: width .25s ease;
}

.control-bar {
  width: calc(100% - 40px);
  margin: 12px auto 20px;
  align-items: center;
  justify-content: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(7, 18, 27, .78);
}

.transition-panel {
  grid-template-columns: 180px 180px minmax(0, 1fr);
  min-height: 360px;
}

.transition-panel.final-complete {
  grid-template-columns: minmax(320px, 480px) minmax(0, 1fr);
  align-items: center;
}

.transition-panel .character,
.game-over-character {
  position: static;
  width: 100%;
  max-width: 180px;
  max-height: 300px;
  object-fit: contain;
}

.transition-panel.final-complete #transition-cipher {
  max-width: 480px;
  max-height: 520px;
}

.transition-panel.final-complete #transition-title {
  font-size: clamp(2.8rem, 5.4vw, 5.2rem);
  line-height: .92;
  color: var(--green);
  text-shadow: 0 0 24px rgba(77, 255, 136, .32);
  white-space: nowrap;
}

.game-over-panel {
  grid-template-columns: 180px minmax(0, 1fr) 180px;
  min-height: 380px;
  align-items: center;
}

.game-over-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.shake { animation: shake .28s ease-in-out; }
.flash-green { animation: flash-green .7s ease-in-out; }
.flash-red { animation: flash-red .7s ease-in-out; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

@keyframes flash-green {
  0%, 100% { filter: none; }
  50% { filter: drop-shadow(0 0 24px var(--green)); }
}

@keyframes flash-red {
  0%, 100% { filter: none; }
  50% { filter: drop-shadow(0 0 24px var(--red)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: .001ms !important;
  }
}

@media (max-width: 980px) {
  .page-shell {
    display: block;
  }

  .game-frame {
    min-height: 100vh;
    border-radius: 0;
  }

  .top-bar,
  .intro-panel,
  .transition-panel,
  .game-over-panel {
    grid-template-columns: 1fr;
  }

  .status-strip {
    justify-content: flex-start;
  }

  .intro-panel,
  .transition-panel,
  .game-over-panel,
  .play-layout,
  .control-bar {
    width: calc(100% - 24px);
  }

  .character-pair {
    min-height: 330px;
  }

  .character {
    max-height: 320px;
  }

  .intro-tiles {
    width: 56%;
    max-height: 230px;
  }
}

@media (max-width: 560px) {
  .top-bar {
    padding: 12px;
  }

  .intro-panel {
    padding: 14px;
  }

  .character-pair {
    min-height: 260px;
  }

  .character {
    max-height: 245px;
  }

  .intro-tiles {
    width: 62%;
    max-height: 180px;
  }

  .control-bar button,
  .intro-actions button {
    flex: 1 1 150px;
  }

  .feedback-row {
    grid-template-columns: 1fr;
  }

  .feedback-row .character {
    display: none;
  }
}


.demo-note {
  margin: 8px 0 12px;
  padding: 10px 12px;
  border: 1px solid rgba(240, 184, 76, .65);
  border-radius: 8px;
  background: rgba(7, 18, 27, .52);
  color: #f9e3aa !important;
  font-weight: 800;
}


/* Edgy English website integration */
.website-home-link,
.website-arcade-link {
  color: var(--ink);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.website-home-link {
  border-color: var(--gold);
  background: rgba(238, 180, 54, 0.18);
}
.website-home-link:hover,
.website-arcade-link:hover {
  border-color: var(--gold);
  color: var(--gold);
}
.buy-full-version {
  font-weight: 900;
  letter-spacing: .03em;
}
.final-tpt-link {
  display: inline-flex;
  margin-top: 12px;
  justify-content: center;
}
.final-tpt-link[hidden] {
  display: none !important;
}


/* Edgy English navigation contrast fix */
.website-arcade-link{
  background:#0b2638 !important;
  color:#f7fbff !important;
  border-color:#35c2d1 !important;
  text-shadow:none !important;
}
.website-arcade-link:hover,
.website-arcade-link:focus-visible{
  background:#10384f !important;
  color:#f0b84c !important;
  border-color:#f0b84c !important;
}
.website-home-link{
  color:#f7fbff !important;
}


/* Sentence Spy opening video - viewport-safe version */
.opening-video-screen{
  position:fixed;
  inset:0;
  z-index:10000;
  display:grid;
  place-items:center;
  padding:12px;
  overflow:hidden;
  background:#02070c;
}
.opening-video-inner{
  width:min(96vw, calc((100dvh - 92px) * 16 / 9), 1280px);
  max-width:1280px;
  display:grid;
  gap:8px;
  justify-items:center;
}
.opening-video-stage{
  position:relative;
  width:100%;
  aspect-ratio:16 / 9;
  overflow:hidden;
  border:1px solid rgba(53,194,209,.7);
  border-radius:10px;
  background:#000;
  box-shadow:0 20px 60px rgba(0,0,0,.55);
}
.opening-video,
.opening-video-poster{
  position:absolute;
  inset:0;
  display:block;
  width:100%;
  height:100%;
  object-fit:contain;
  background:#000;
}
.opening-video{
  z-index:1;
}
.opening-video-poster{
  z-index:2;
}
.opening-video-controls{
  position:absolute;
  z-index:4;
  left:50%;
  bottom:16px;
  transform:translateX(-50%);
  display:flex;
  gap:10px;
  justify-content:center;
  align-items:center;
  padding:8px;
  border-radius:12px;
  background:rgba(2,7,12,.76);
  box-shadow:0 8px 24px rgba(0,0,0,.3);
}
.opening-video-controls button{
  min-height:44px;
  padding:0 18px;
  border:2px solid #d9e4ea;
  border-radius:8px;
  background:#f7fbff;
  color:#14212b;
  font-weight:900;
  white-space:nowrap;
}
.opening-video-controls .primary{
  border-color:#35c2d1;
  background:#35c2d1;
  color:#07121b;
}
.opening-video-controls button:hover,
.opening-video-controls button:focus-visible{
  border-color:#f0b84c;
  outline:none;
}
.opening-video-note{
  margin:0;
  color:#c6d3dc;
  font-size:13px;
  font-weight:800;
}
.opening-video-screen.video-playing .opening-video-poster{
  display:none;
}
.opening-video-screen.video-playing #play-opening-video{
  display:none;
}
@media(max-width:700px){
  .opening-video-inner{
    width:min(97vw, calc((100dvh - 76px) * 16 / 9));
  }
  .opening-video-controls{
    bottom:8px;
    gap:6px;
    padding:6px;
  }
  .opening-video-controls button{
    min-height:38px;
    padding:0 12px;
    font-size:12px;
  }
  .opening-video-note{
    font-size:11px;
  }
}
