:root {
  --bg-a: #051126;
  --bg-b: #102f50;
  --bg-c: #1c3f5d;
  --ink-main: #e9f6ff;
  --ink-dim: #99b4ca;
  --accent-1: #72f8d8;
  --accent-2: #ffc965;
  --accent-3: #ff6f91;
  --card-bg: rgba(7, 16, 29, 0.86);
  --card-border: rgba(128, 190, 228, 0.26);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  color: var(--ink-main);
  background: radial-gradient(1200px 700px at 8% 7%, #15456e 0%, transparent 58%),
    radial-gradient(900px 500px at 90% 9%, #1d5a74 0%, transparent 62%),
    linear-gradient(160deg, var(--bg-a) 12%, var(--bg-b) 56%, var(--bg-c) 100%);
  overflow-x: hidden;
}

.app-shell {
  width: min(1460px, 96vw);
  margin: 0 auto;
  padding: 1rem 0 1.6rem;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 420px);
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  padding: 0.9rem 1.05rem;
  border-radius: 18px;
  border: 1px solid rgba(145, 217, 238, 0.24);
  background: linear-gradient(140deg, rgba(5, 24, 40, 0.72), rgba(14, 53, 74, 0.44)),
    url("../img/med-grid.svg");
  background-size: cover, 230px;
  background-repeat: no-repeat, repeat;
  box-shadow: 0 16px 36px rgba(4, 11, 18, 0.32);
  overflow: hidden;
}

.hero-copy {
  position: relative;
  z-index: 1;
}

.eyebrow {
  margin: 0;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent-1);
  font-size: 0.8rem;
}

h1 {
  margin: 0;
  font-family: "Bebas Neue", "Segoe UI", sans-serif;
  letter-spacing: 0.06em;
  font-size: clamp(2.2rem, 5vw, 4.2rem);
}

.subtitle {
  margin: 0.2rem 0 0;
  color: var(--ink-dim);
  max-width: 70ch;
  line-height: 1.45;
}

.mobile-keyboard-warning {
  margin: 0.6rem 0 0;
  max-width: 56ch;
  border-radius: 10px;
  border: 1px solid rgba(255, 201, 101, 0.45);
  background: linear-gradient(130deg, rgba(49, 29, 10, 0.6), rgba(66, 40, 13, 0.52));
  color: #ffe7b5;
  font-size: 0.84rem;
  line-height: 1.42;
  padding: 0.52rem 0.62rem;
}

.hub-link-wrap {
  margin: 0.7rem 0 0;
}

.hub-link {
  color: var(--accent-1);
  text-decoration: none;
  font-weight: 600;
}

.hub-link:hover {
  text-decoration: underline;
}

.hero-art {
  margin: 0;
  width: min(100%, 420px);
  justify-self: end;
  filter: drop-shadow(0 14px 24px rgba(4, 11, 18, 0.45));
}

.hero-art img {
  display: block;
  width: 100%;
  height: auto;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 370px;
  gap: 1.05rem;
  align-items: stretch;
}

.game-panel {
  position: relative;
  border-radius: 22px;
  overflow: hidden;
  border: 1px solid rgba(132, 196, 230, 0.28);
  box-shadow: 0 26px 58px rgba(2, 8, 14, 0.45);
  min-height: 0;
  background: linear-gradient(160deg, rgba(7, 14, 24, 0.84), rgba(9, 27, 43, 0.84));
}

#game-canvas {
  display: block;
  width: min(100%, calc(74vh * 16 / 9));
  aspect-ratio: 16 / 9;
  height: auto;
  max-height: 74vh;
  margin: 0 auto;
  image-rendering: auto;
}

.typing-input {
  position: absolute;
  left: -1000px;
  opacity: 0;
  pointer-events: none;
}

.control-panel {
  display: grid;
  gap: 0.8rem;
  align-content: start;
  position: sticky;
  top: 0.8rem;
}

.card {
  background: var(--card-bg);
  border: 1px solid rgba(136, 198, 226, 0.24);
  border-radius: 20px;
  padding: 0.9rem;
  backdrop-filter: blur(6px);
  box-shadow: 0 12px 30px rgba(3, 10, 18, 0.26);
}

.card h2 {
  margin: 0 0 0.6rem;
  font-family: "Bebas Neue", "Segoe UI", sans-serif;
  font-weight: 400;
  letter-spacing: 0.08em;
  font-size: 1.65rem;
}

label {
  display: grid;
  gap: 0.34rem;
  margin-bottom: 0.6rem;
  color: var(--ink-dim);
  font-size: 0.88rem;
}

input[type="text"],
select {
  width: 100%;
  border-radius: 11px;
  border: 1px solid rgba(130, 205, 224, 0.37);
  background: rgba(16, 32, 50, 0.82);
  color: var(--ink-main);
  padding: 0.52rem 0.62rem;
  font: inherit;
}

button {
  width: 100%;
  border: 0;
  border-radius: 11px;
  padding: 0.62rem 0.75rem;
  margin-top: 0.5rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  color: #071724;
  background: linear-gradient(120deg, var(--accent-1), #9fffc9 70%);
  transition: transform 120ms ease, filter 120ms ease;
}

button:hover {
  transform: translateY(-1px);
  filter: brightness(1.04);
}

button:active {
  transform: translateY(1px);
}

.secondary-btn {
  background: linear-gradient(120deg, var(--accent-2), #ffe7a4 70%);
}

.toggle-line {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0.25rem 0 0.2rem;
}

.toggle-line input {
  accent-color: var(--accent-1);
}

.status-line {
  margin: 0.56rem 0 0;
  font-size: 0.81rem;
  color: var(--ink-dim);
}

.caption {
  margin: -0.25rem 0 0.5rem;
  color: var(--ink-dim);
  font-size: 0.8rem;
}

.board-wrap {
  max-height: 370px;
  overflow: auto;
  border: 1px solid rgba(136, 198, 226, 0.22);
  border-radius: 10px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  table-layout: fixed;
}

th,
td {
  text-align: left;
  padding: 0.34rem;
  border-bottom: 1px dashed rgba(139, 192, 224, 0.2);
  white-space: normal;
  overflow-wrap: anywhere;
}

th:nth-child(1),
td:nth-child(1),
th:nth-child(3),
td:nth-child(3),
th:nth-child(4),
td:nth-child(4),
th:nth-child(5),
td:nth-child(5) {
  text-align: center;
}

th {
  color: var(--accent-1);
}

tbody tr:nth-child(1) td {
  color: #ffe089;
  font-weight: 700;
}

tbody tr:nth-child(2) td,
tbody tr:nth-child(3) td {
  color: #c5efff;
}

.powered-by {
  margin-top: 1rem;
  text-align: center;
}

.powered-by a {
  color: #9bcce6;
  text-decoration: none;
  font-size: 0.84rem;
  font-weight: 600;
}

.powered-by a:hover {
  text-decoration: underline;
}

@media (max-width: 1100px) {
  .hero {
    grid-template-columns: minmax(0, 1fr);
  }

  .hero-art {
    justify-self: start;
    width: min(100%, 500px);
  }

  .layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .control-panel {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    position: static;
  }
}

@media (max-width: 740px) {
  .app-shell {
    width: min(96vw, 100%);
    padding-top: 0.8rem;
  }

  .hero {
    margin-bottom: 0.7rem;
    padding: 0.75rem;
  }

  .hero-art {
    display: none;
  }

  .subtitle {
    font-size: 0.93rem;
  }

  #game-canvas {
    width: min(100%, calc(56vh * 16 / 9));
    max-height: 52vh;
  }

  .card {
    padding: 0.8rem;
  }

  .control-panel {
    grid-template-columns: minmax(0, 1fr);
  }

  .board-wrap {
    max-height: 280px;
  }

  table {
    font-size: 0.73rem;
  }
}

@media (max-width: 520px) {
  .app-shell {
    width: min(97vw, 100%);
    padding-top: 0.6rem;
    padding-bottom: calc(1rem + env(safe-area-inset-bottom));
  }

  .hero {
    border-radius: 14px;
  }

  .game-panel {
    border-radius: 14px;
  }

  #game-canvas {
    width: min(100%, calc(48vh * 16 / 9));
    max-height: 48vh;
  }
}
