:root {
  color-scheme: light;
  --ink: #1d1712;
  --muted: #6c6257;
  --paper: #fff8e7;
  --paper-deep: #f4e7c1;
  --green: #75985b;
  --green-dark: #35583c;
  --red: #a54a3f;
  --gold: #d9aa45;
  --line: #272018;
  font-family: "Trebuchet MS", "Arial Rounded MT Bold", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(70, 97, 67, 0.78) 0 12px, transparent 12px 100%),
    linear-gradient(0deg, rgba(144, 58, 47, 0.22) 0 12px, transparent 12px 100%),
    #dae6bd;
  background-size: 42px 42px;
}

button,
input {
  font: inherit;
}

.shell {
  width: min(100%, 720px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px clamp(12px, 3vw, 28px) 28px;
  background:
    radial-gradient(circle at 20% 10%, rgba(255, 255, 255, 0.8), transparent 28%),
    linear-gradient(#d9ecf2 0 22%, #c4d99a 22% 100%);
  border-left: 8px solid rgba(39, 32, 24, 0.28);
  border-right: 8px solid rgba(39, 32, 24, 0.28);
}

.hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 0 22px;
}

.eyebrow,
.player-label {
  margin: 0 0 4px;
  color: var(--green-dark);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1;
}

h1 {
  max-width: 13ch;
  font-size: clamp(2.2rem, 7vw, 4.2rem);
}

h2 {
  font-size: clamp(1.8rem, 6vw, 3rem);
}

.ghost {
  min-height: 42px;
  padding: 0 14px;
  border: 2px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255, 248, 231, 0.82);
  box-shadow: 3px 3px 0 var(--line);
}

.login-panel,
.game {
  background: rgba(255, 248, 231, 0.86);
  border: 3px solid var(--line);
  border-radius: 8px;
  box-shadow: 6px 6px 0 rgba(39, 32, 24, 0.26);
}

.login-panel {
  padding: 18px;
}

.login-form label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-weight: 800;
}

.login-row {
  display: flex;
  gap: 10px;
}

input {
  width: 100%;
  min-height: 50px;
  padding: 0 14px;
  border: 3px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fffdf5;
}

.login-row button {
  min-width: 92px;
  min-height: 50px;
  border: 3px solid var(--line);
  border-radius: 8px;
  color: #fffdf5;
  background: var(--green-dark);
  box-shadow: 3px 3px 0 var(--line);
}

.game {
  padding: clamp(10px, 2vw, 18px);
}

.game-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.score {
  display: grid;
  min-width: 70px;
  min-height: 54px;
  place-items: center;
  border: 3px solid var(--line);
  border-radius: 8px;
  background: var(--gold);
  font-size: 1.3rem;
  font-weight: 900;
}

.board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(6px, 1.6vw, 10px);
}

.tile {
  position: relative;
  display: block;
  aspect-ratio: 266 / 351;
  padding: 6px;
  overflow: hidden;
  border: 3px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  box-shadow: 0 2px 0 rgba(39, 32, 24, 0.24);
  cursor: pointer;
}

.tile img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.tile::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(117, 152, 91, 0);
  transition: background 140ms ease;
}

.tile[aria-pressed="true"]::after {
  background: rgba(117, 152, 91, 0.34);
}

.check {
  position: absolute;
  top: 2.8%;
  left: 3.8%;
  z-index: 1;
  width: 18%;
  aspect-ratio: 1;
  pointer-events: none;
}

.tile[aria-pressed="true"] .check::before {
  content: "✓";
  position: absolute;
  inset: -28% 0 0;
  display: grid;
  place-items: center;
  color: var(--red);
  font-size: clamp(1.35rem, 6vw, 3rem);
  font-weight: 900;
  line-height: 1;
}

.status {
  min-height: 30px;
  margin-top: 12px;
  color: var(--muted);
  font-weight: 800;
  text-align: center;
}

.status.win {
  color: var(--red);
  font-size: 1.2rem;
}

.status.error {
  color: var(--red);
}

.hidden {
  display: none;
}

.loading {
  opacity: 0.62;
  pointer-events: none;
}

@media (max-width: 520px) {
  .shell {
    border-width: 0;
  }

  .hero {
    align-items: flex-end;
  }

  .ghost {
    min-width: 44px;
    padding: 0 10px;
  }

  .login-row {
    flex-direction: column;
  }

  .login-row button {
    width: 100%;
  }

  .game-top {
    margin-bottom: 8px;
  }

  .tile,
  .login-panel,
  .game {
    border-width: 2px;
  }
}
