@import url("./fonts.css");

:root {
  color-scheme: dark;
  --background: #101d1a;
  --panel: #192823;
  --border: #34463c;
  --text: #fff3d7;
  --muted: #b7c3b5;
  --gold: #f6c96f;
  --mint: #93c8aa;
  --display: "Fraunces", Georgia, serif;
  --body: "DM Sans", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-width: 300px;
  background: radial-gradient(ellipse at 85% 0%, #1d3228 0%, transparent 57%), var(--background);
  color: var(--text);
  font-family: var(--body);
  font-size: 1rem;
  -webkit-tap-highlight-color: transparent;
}

button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; cursor: pointer; }
button:focus-visible, a:focus-visible { outline: 3px solid #fff1c5; outline-offset: 4px; }
button:disabled { cursor: default; opacity: .55; }
p, h1, h2, h3 { margin: 0; }

.site-header, .site-main {
  width: min(100% - 5.25rem, 76.25rem);
  margin-inline: auto;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 5.5rem;
}
.brand, .header-actions { display: flex; align-items: center; gap: .7rem; }
.brand { gap: .85rem; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 2.6rem;
  height: 2.6rem;
  border: 1px solid #53614a;
  border-radius: .72rem;
  background: #283b2d;
  box-shadow: inset 0 0 0 3px #24372c;
}
.brand-mark span {
  width: 1.4rem;
  height: 1.4rem;
  background: var(--gold);
  clip-path: polygon(50% 0, 61% 39%, 100% 50%, 61% 61%, 50% 100%, 39% 61%, 0 50%, 39% 39%);
}
.brand-title { font-size: 1.14rem; line-height: 1.1; font-weight: 800; }
.brand-description { margin-top: .22rem; color: var(--muted); font-size: .82rem; }

.outline-button, .primary-button, .secondary-button {
  min-height: 2.65rem;
  padding: .58rem .88rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .57rem;
  border: 1px solid #526556;
  border-radius: .6rem;
  color: var(--text);
  background: #23352b;
  font-weight: 700;
  white-space: nowrap;
  transition: background .16s ease, border-color .16s ease, transform .16s ease;
}

.outline-button { background: transparent; font-size: .87rem; color: #e3e8db; }
.outline-button:hover, .secondary-button:hover { background: #354a3a; border-color: #9ea88e; }
.primary-button {
  color: #251c12;
  background: var(--gold);
  border-color: #ffdc91;
  box-shadow: 0 3px 0 #a06b34;
  font-weight: 800;
}
.primary-button:hover { background: #ffdb8f; }
.primary-button:active, .secondary-button:active { transform: translateY(2px); }

.keyboard-icon {
  width: 1rem;
  height: .72rem;
  border: 1.5px solid currentColor;
  border-radius: .15rem;
  background: repeating-linear-gradient(90deg, currentColor 0 1px, transparent 1px 3px) center 2px / 8px 2px no-repeat,
    linear-gradient(currentColor, currentColor) center 5px / 5px 1px no-repeat;
}
.sound-icon { font-size: 1.18rem; line-height: .9; }
.sound-button[aria-pressed="false"] .sound-icon { opacity: .55; text-decoration: line-through; }

.hero {
  position: relative;
  isolation: isolate;
  display: flex;
  align-items: center;
  min-height: 34.3rem;
  overflow: hidden;
  border: 1px solid #54715c;
  border-radius: 1.15rem;
  background: #183d37;
  box-shadow: 0 18px 60px #080e0c66;
}
.hero-art, .hero-art::after { position: absolute; z-index: -1; inset: 0; }
.hero-art {
  background: url("./island-cover.webp") 52% 52% / cover no-repeat;
}
.hero-art::after {
  content: "";
  background: linear-gradient(90deg, #101e19f2 0%, #112520e0 20%, #1428209f 41%, #182c2400 68%),
    linear-gradient(0deg, #131e19a1, transparent 29%);
}
.hero-content {
  width: min(100%, 37rem);
  padding: 2.6rem 1rem 2.7rem clamp(2rem, 6vw, 5.15rem);
}
.hero-eyebrow {
  display: flex;
  gap: .57rem;
  align-items: center;
  margin-bottom: 1.12rem;
  color: #ffdfa0;
  font-size: .87rem;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.hero-eyebrow span {
  display: inline-block;
  width: .48rem;
  height: .48rem;
  border-radius: .07rem;
  transform: rotate(45deg);
  background: currentColor;
}
.hero h1 {
  max-width: 6ch;
  font: 900 clamp(4.4rem, 8.9vw, 8.5rem) / .85 var(--display);
  letter-spacing: -.07em;
  text-shadow: 0 3px 22px #101e1999;
}
.hero h1 em { color: var(--gold); font-style: normal; }
.hero-description {
  max-width: 26rem;
  margin-top: 1.55rem;
  color: #f2eddb;
  font-size: 1.09rem;
  line-height: 1.55;
}
.hero-actions, .status-actions { display: flex; flex-wrap: wrap; gap: .7rem; }
.hero-actions { margin-top: 1.65rem; }
.hero-actions button { min-height: 3.25rem; padding: .72rem 1rem; }
.hero-actions .secondary-button { background: #1d2f27d9; border-color: #9ca78a; }
.hero-actions .secondary-button:hover { background: #3b503b; }
.mode-note { color: #e1e0c9; margin-top: 1rem; font-size: .88rem; }
.play-icon {
  width: .77rem;
  height: .89rem;
  background: currentColor;
  clip-path: polygon(6% 0, 97% 50%, 6% 100%);
}
.duo-icon { position: relative; display: inline-block; width: 1.14rem; height: 1.05rem; }
.duo-icon::before, .duo-icon::after {
  content: "";
  position: absolute;
  width: .75rem;
  height: .85rem;
  bottom: .05rem;
  background: radial-gradient(circle at center .22rem, currentColor .17rem, transparent .19rem),
    radial-gradient(ellipse at center bottom, currentColor .31rem, transparent .34rem);
}
.duo-icon::before { left: 0; }
.duo-icon::after { right: 0; opacity: .63; }

.mission { margin: 1.65rem 0 1.7rem; }
.mission h2 {
  margin-bottom: .85rem;
  color: #f5eacf;
  font: 760 clamp(1.55rem, 2.35vw, 2rem) / 1.1 var(--display);
  letter-spacing: -.028em;
}
.mission-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .85rem; }
.mission-card {
  display: flex;
  align-items: flex-start;
  gap: .85rem;
  min-width: 0;
  padding: 1.03rem;
  border: 1px solid var(--border);
  border-radius: .8rem;
  background: linear-gradient(120deg, #22342b, #1a2823);
}
.mission-card h3 { margin-bottom: .25rem; font-size: 1rem; line-height: 1.2; font-weight: 800; }
.mission-card p { color: var(--muted); font-size: .9rem; line-height: 1.45; }
.mission-icon {
  position: relative;
  display: grid;
  place-items: center;
  flex: none;
  width: 2.7rem;
  height: 2.7rem;
  border: 1px solid #6c5c3b;
  border-radius: .56rem;
  background: #453c29;
  color: #f1c775;
}
.chest-icon i {
  width: 1.2rem;
  height: .92rem;
  border: 2px solid currentColor;
  border-radius: 4px 4px 2px 2px;
  background: linear-gradient(currentColor, currentColor) center 3px / 100% 2px no-repeat;
}
.chest-icon i::after {
  content: "";
  display: block;
  margin: .22rem auto 0;
  width: .27rem;
  height: .33rem;
  border-radius: 1px;
  background: currentColor;
}
.shield-icon { color: #ffac9d; border-color: #6c5146; background: #44332d; }
.shield-icon i {
  width: 1.24rem;
  height: 1.24rem;
  background: currentColor;
  clip-path: polygon(50% 0%, 96% 16%, 90% 64%, 74% 85%, 50% 100%, 26% 85%, 10% 64%, 4% 16%);
}
.shield-icon i::after {
  content: "♥";
  display: grid;
  place-items: center;
  height: 100%;
  color: #44332d;
  font: 700 .66rem/1 var(--body);
}
.beacon-icon { color: #aadcbb; border-color: #57735b; background: #2d493a; }
.beacon-icon i {
  width: 1.26rem;
  height: 1.32rem;
  background: currentColor;
  clip-path: polygon(50% 0, 78% 22%, 69% 24%, 69% 45%, 63% 45%, 75% 89%, 92% 89%, 92% 99%, 8% 99%, 8% 89%, 25% 89%, 37% 45%, 31% 45%, 31% 24%, 22% 22%);
}
.site-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: .85rem 0 1.25rem;
  border-top: 1px solid #304238;
  color: #a2b3a6;
  font-size: .88rem;
}
.site-footer a { color: #c4d8c3; text-underline-offset: .2rem; }
.site-footer a:hover { color: var(--gold); }

body[data-state="menu"] #play-screen { display: none; }
body:not([data-state="menu"]) .site-header,
body:not([data-state="menu"]) .site-main { width: min(100% - 3rem, 72rem); }
body:not([data-state="menu"]) .site-header { min-height: 4.6rem; }
#play-screen { padding-bottom: 1rem; }
.hud {
  display: flex;
  align-items: stretch;
  gap: .45rem;
  padding: .5rem;
  margin-bottom: .55rem;
  border: 1px solid #435849;
  border-radius: .82rem;
  background: #1c3027;
}
.hud-item {
  display: grid;
  place-content: center start;
  flex: 1 0 auto;
  min-width: 0;
  padding: .05rem .85rem;
  border-right: 1px solid #3a5242;
}
.player-item { flex-grow: 1.15; }
.weapon-item { flex-grow: 1.25; border-right: none; }
.hud-caption {
  color: #c4d5c1;
  font-size: .73rem;
  font-weight: 750;
  letter-spacing: .07em;
  text-transform: uppercase;
}
.hud-item strong { font-size: 1.25rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
#score { color: var(--gold); }
#hearts { display: flex; flex-wrap: nowrap; gap: .15rem; color: #ff8275; font-size: 1.35rem; line-height: 1.3; white-space: nowrap; }
#hearts .heart-empty { color: #755b53; }
.pause-button { align-self: center; }
.pause-button span:first-child { color: #f1ce84; font-weight: 900; font-size: 1rem; }
.game-frame {
  position: relative;
  display: grid;
  place-items: center;
  border: 1px solid #52776a;
  border-radius: .92rem;
  overflow: hidden;
  background: #123b42;
  box-shadow: 0 12px 55px #07201c99;
}
#game-canvas {
  display: block;
  height: auto;
  width: 100%;
  max-height: calc(100dvh - 12.1rem);
  min-height: 15rem;
  object-fit: contain;
  touch-action: none;
  cursor: crosshair;
  outline: none;
}
.game-objective, .interaction-hint {
  position: absolute;
  z-index: 1;
  pointer-events: none;
  padding: .52rem .75rem;
  border: 1px solid #6b8872;
  border-radius: .5rem;
  background: #142a25e8;
  color: #ffefd1;
  font-weight: 750;
  font-size: .89rem;
  text-align: center;
}
.game-objective { top: .8rem; left: .8rem; }
.objective-mark { color: var(--gold); margin-right: .35rem; }
.interaction-hint { left: 50%; bottom: .8rem; transform: translateX(-50%); max-width: 90%; border-color: #ebc271; }
.interaction-hint:empty { display: none; }
.quick-guide { display: flex; justify-content: center; gap: .75rem 1.45rem; flex-wrap: wrap; margin-top: .75rem; color: #bacabd; font-size: .85rem; }
kbd {
  display: inline-flex;
  justify-content: center;
  min-width: 1.32rem;
  padding: .07rem .25rem;
  margin-right: .15rem;
  border: 1px solid #627969;
  border-bottom-width: 2px;
  border-radius: .24rem;
  color: #f5ead4;
  background: #243b31;
  font-family: var(--body);
  font-size: .8rem;
  line-height: 1.15;
}
.touch-controls { display: none; }
body:not([data-state="menu"]) #game-overlay:not([hidden]) {
  position: fixed;
  z-index: 5;
  inset: 0;
  overflow: auto;
  display: grid;
  place-items: center;
  padding: 1.2rem;
  background: #09140fbc;
}
.status-card, #controls-dialog {
  color: var(--text);
  border: 1px solid #688370;
  border-radius: 1rem;
  background: #1d332a;
  box-shadow: 0 25px 120px #050c08bc;
}
.status-card { width: min(100%, 33rem); padding: clamp(1.25rem, 4.4vw, 2.7rem); }
.status-card h2, #controls-dialog h2 {
  color: #fff2d7;
  font: 820 clamp(2rem, 5vw, 3.5rem) / .99 var(--display);
  letter-spacing: -.04em;
}
.status-card #overlay-description { color: #dfebdc; line-height: 1.55; margin-top: .9rem; white-space: pre-line; }
.status-card #duo-summary { color: var(--gold); font-weight: 800; margin-top: .85rem; }
.status-actions { margin-top: 1.35rem; gap: .65rem; }
.status-actions button { white-space: normal; }
#controls-dialog { width: min(100% - 1.5rem, 32rem); padding: 1.45rem; }
#controls-dialog::backdrop { background: #080e0bc9; }
.dialog-header { display: flex; justify-content: space-between; align-items: center; gap: .7rem; }
#controls-dialog h2 { font-size: 2.35rem; }
.dialog-close { min-width: 2.65rem; font-size: 1.5rem; line-height: 1; }
.control-list { margin: .9rem 0; }
.control-list div { display: grid; grid-template-columns: minmax(6rem, 1fr) 1.65fr; align-items: center; gap: .5rem .8rem; padding: .53rem 0; border-bottom: 1px solid #40594a; }
.control-list dt { font-weight: 800; }
.control-list dd { color: #e5eede; margin: 0; }
.touch-note, .no-script { color: var(--muted); line-height: 1.45; }
.no-script { margin: 1rem auto; padding: 1rem; text-align: center; }

@media (max-width: 64rem) {
  .site-header, .site-main { width: min(100% - 3rem, 76.25rem); }
  .hero { min-height: 32rem; }
  .hero-content { padding-left: clamp(2rem, 5vw, 5rem); }
  .hero h1 { font-size: clamp(4.3rem, 11.2vw, 7.1rem); }
}
@media (max-width: 48rem) {
  .site-header, .site-main,
  body:not([data-state="menu"]) .site-header,
  body:not([data-state="menu"]) .site-main { width: calc(100% - 1.6rem); }
  .site-header, body:not([data-state="menu"]) .site-header { min-height: 4.3rem; }
  .mission-grid { gap: .58rem; }
  .mission-card { padding: .72rem; gap: .54rem; }
  .mission-icon { width: 2.2rem; height: 2.2rem; }
  .hud { gap: 0; }
  .hud-item { padding-inline: .5rem; }
  .hud-item strong { font-size: 1.05rem; }
  .pause-button span:last-child { display: none; }
  .game-objective { top: .45rem; left: .45rem; font-size: .75rem; }
}
@media (max-width: 37.5rem) {
  .brand { gap: .5rem; }
  .brand-title { font-size: 1rem; }
  .brand-description { font-size: .75rem; }
  .brand-mark { width: 2.25rem; height: 2.25rem; }
  .header-actions { gap: .35rem; }
  .header-actions button { padding-inline: .45rem; }
  .sound-name { display: none; }
  .sound-button { width: 2.3rem; }
  .hero { align-items: end; min-height: 34rem; border-radius: .87rem; }
  .hero-art { background-position: 62% 18%; background-size: auto 80%; }
  .hero-art::after {
    background: linear-gradient(0deg, #14231d 10%, #14231df5 29%, #14231d9e 58%, #14231d00 86%),
      linear-gradient(90deg, #0e1e1b61, transparent 65%);
  }
  .hero-content { padding: 1.15rem; }
  .hero h1 { font-size: clamp(3.8rem, 14vw, 5.2rem); }
  .hero-eyebrow { font-size: .74rem; margin-bottom: .72rem; }
  .hero-description { font-size: .97rem; margin-top: .9rem; }
  .hero-actions { gap: .53rem; margin-top: 1rem; }
  .hero-actions button { min-height: 2.95rem; padding: .64rem .69rem; font-size: .91rem; }
  .mode-note { font-size: .83rem; margin-top: .85rem; }
  .mission-grid { grid-template-columns: 1fr; }
  .mission-card { padding: .76rem; gap: .75rem; }
  .mission { margin-block: 1.25rem; }
  .hud { display: grid; grid-template-columns: 1.2fr 1fr 1fr auto; gap: .42rem 0; }
  .hud-caption { font-size: .65rem; }
  .hud-item { padding-inline: .4rem; }
  .weapon-item { grid-area: 2 / 3 / 3 / 5; }
  .high-score-item { grid-area: 2 / 1 / 3 / 3; }
  .pause-button { min-height: 2.3rem; padding: 0 .6rem; }
  #hearts { font-size: .99rem; gap: .06rem; }
  #game-canvas { min-height: 9rem; }
}
@media (pointer: coarse), (hover: none) {
  .touch-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .6rem;
    width: 100%;
    padding: .45rem .58rem;
    background: #1c3027;
  }
  #joystick {
    position: relative;
    flex: none;
    width: 4.6rem;
    height: 4.6rem;
    border: 1px solid #648572;
    border-radius: 50%;
    background: #2b4438;
    touch-action: none;
  }
  .joystick-thumb {
    position: absolute;
    left: calc(50% - 1.1rem);
    top: calc(50% - 1.1rem);
    width: 2.2rem;
    height: 2.2rem;
    border-radius: 50%;
    background: #a5c9a5;
    pointer-events: none;
  }
  .touch-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .38rem; }
  .touch-actions button {
    min-height: 2.75rem;
    padding: .4rem .65rem;
    border: 1px solid #a1ad80;
    border-radius: .55rem;
    color: var(--text);
    background: #314d3c;
    font-size: .85rem;
    font-weight: 750;
    touch-action: none;
  }
  #touch-attack { color: #2a2011; background: var(--gold); }
  .interaction-hint { bottom: 6rem; }
  .quick-guide { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
