:root {
  --bg: #101a2d;
  --panel: #1c2a43;
  --panel2: #243650;
  --ink: #f3f6ff;
  --muted: #b7c4dc;
  --gold: #ffd76a;
  --cyan: #64ead5;
  --pink: #ff7c9e;
  --line: #3a5272;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: radial-gradient(ellipse at 50% -20%, #315477 0, transparent 60%), var(--bg);
  color: var(--ink);
  font:
    15px/1.45 system-ui,
    Segoe UI,
    sans-serif;
}
button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px max(17px, calc((100vw - 1200px) / 2));
  border-bottom: 1px solid var(--line);
  background: #101a2de8;
}
.brand {
  font-weight: 900;
  letter-spacing: 0.1em;
  color: var(--gold);
  font-size: 0.8rem;
}
.top a {
  color: var(--cyan);
  text-decoration: none;
  font-size: 0.85rem;
}
.wrap {
  max-width: 1200px;
  margin: 17px auto;
  padding: 0 16px;
}
.intro {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 12px;
  margin-bottom: 12px;
}
.panel {
  background: linear-gradient(145deg, #263750, #19263d);
  border: 1px solid #49617e;
  border-radius: 15px;
  padding: 14px;
  box-shadow: 0 5px 15px #050b1855;
}
.eyebrow {
  color: var(--cyan);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.13em;
}
h1 {
  font-size: clamp(1.55rem, 3.4vw, 2.35rem);
  line-height: 1.05;
  color: var(--gold);
  margin: 0.3rem 0 0.5rem;
}
p {
  margin: 0.4rem 0;
  color: #d9e2f4;
}
.roles {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 9px;
}
.roles span {
  padding: 4px 8px;
  border-radius: 99px;
  background: #344761;
  border: 1px solid #56708e;
  font-size: 0.68rem;
}
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
}
.stat {
  padding: 8px 4px;
  border-radius: 10px;
  text-align: center;
  background: #111d31;
  border: 1px solid #364d69;
}
.stat b {
  display: block;
  color: var(--gold);
  font-size: 1rem;
}
.stat small {
  color: var(--muted);
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}
.instructions {
  font-size: 0.72rem;
  color: #d7e5f6;
  margin-top: 9px;
}
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 245px;
  gap: 12px;
  align-items: start;
}
.board-panel {
  padding: 12px;
}
.boardhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 2px 8px;
}
.boardhead strong {
  color: var(--cyan);
  font-size: 0.84rem;
}
.boardhead span {
  font-size: 0.7rem;
  color: var(--gold);
  font-weight: 800;
}
.memory-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 7px;
  max-width: 900px;
  margin: auto;
}
.tile {
  position: relative;
  min-width: 0;
  height: clamp(64px, 8.5vh, 82px);
  padding: 5px;
  border: 1px solid #6e8eaf;
  border-radius: 11px;
  background: linear-gradient(145deg, #3a5271, #233550);
  box-shadow: 0 4px #101b2e;
  transition:
    transform 0.16s,
    background 0.2s,
    border-color 0.2s;
  overflow: hidden;
}
.tile:hover:not(:disabled) {
  transform: translateY(-2px);
  border-color: #ffe28c;
}
.tile.flipped,
.tile.face-up {
  animation: flipIn 0.22s ease-out;
}
.tile.face-up .back {
  display: none;
}
.tile.face-up .front {
  display: flex;
}
@keyframes flipIn {
  from {
    transform: rotateY(82deg) scale(0.86);
  }
  to {
    transform: rotateY(0) scale(1);
  }
}
.tile:disabled {
  cursor: default;
}
.tile .back {
  display: flex;
  height: 100%;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: #e1eafa;
  font-weight: 900;
}
.tile .back i {
  font-style: normal;
  font-size: 1.35rem;
  color: var(--gold);
  text-shadow: 0 2px #795e25;
}
.tile .coord {
  position: absolute;
  left: 5px;
  top: 4px;
  color: #b8c8dd;
  font-size: 0.52rem;
}
.tile .front {
  display: none;
  height: 100%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
}
.tile.flipped,
.tile.matched {
  background: linear-gradient(150deg, #f5f1e6, #dbe3ea);
  color: #1c2e45;
  border-color: #fff;
}
.tile.flipped.signal,
.tile.matched.signal {
  background: linear-gradient(150deg, #fff0ee, #ffd6dc);
  border-color: #ffb6c3;
}
.tile.flipped.support,
.tile.matched.support {
  background: linear-gradient(150deg, #e4fff8, #b8f0e4);
  border-color: #85dfcf;
}
.tile.flipped .back,
.tile.matched .back {
  display: none;
}
.tile.flipped .front,
.tile.matched .front {
  display: flex;
}
.kind {
  font-size: 0.48rem;
  letter-spacing: 0.1em;
  font-weight: 1000;
  color: #44607e;
}
.tile.signal .kind {
  color: #b34463;
}
.tile.support .kind {
  color: #147967;
}
.icon {
  font-size: clamp(15px, 2vw, 22px);
  line-height: 1.1;
}
.faceText {
  font-size: clamp(0.53rem, 0.72vw, 0.67rem);
  line-height: 1.1;
  font-weight: 850;
  max-width: 98%;
  text-align: center;
  color: #22344c;
}
.matched {
  box-shadow:
    0 0 0 2px #63dcc5,
    0 4px #101b2e;
}
.toolbar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  margin: 9px 0 0;
}
.toolbar button,
.action {
  padding: 8px 11px;
  border: 1px solid #557393;
  border-radius: 9px;
  background: #2c405e;
  font-weight: 850;
  font-size: 0.72rem;
}
.toolbar button:hover,
.action:hover {
  background: #3d5676;
}
.toolbar .primary {
  background: #e3b93f;
  border-color: #ffdf7a;
  color: #162338;
}
.toast {
  height: 21px;
  text-align: center;
  color: var(--gold);
  font-size: 0.69rem;
  padding-top: 3px;
}
.side .panel {
  margin-bottom: 10px;
}
.side h2 {
  font-size: 0.83rem;
  margin: 0 0 7px;
  color: var(--cyan);
}
.side ul {
  margin: 5px 0;
  padding-left: 17px;
  color: #dce6f5;
  font-size: 0.69rem;
}
.side li {
  margin: 5px 0;
}
.active-team {
  padding: 9px;
  border-radius: 10px;
  background: #111d31;
  color: var(--gold);
  font-weight: 900;
  font-size: 0.78rem;
}
.ledger {
  display: grid;
  gap: 5px;
  margin-top: 8px;
  max-height: 250px;
  overflow: auto;
}
.ledger span {
  padding: 6px;
  border-radius: 7px;
  background: #253750;
  font-size: 0.65rem;
  color: #e4edf9;
}
.note {
  font-size: 0.65rem;
  color: var(--muted);
  margin-top: 8px;
}
.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 16px;
  background: #07101cdd;
}
.overlay[hidden] {
  display: none;
}
.dialog {
  width: min(510px, 100%);
  padding: 23px;
  background: linear-gradient(145deg, #263750, #17243b);
  border: 2px solid #7192af;
  border-radius: 17px;
  box-shadow: 0 20px 70px #0009;
  text-align: center;
}
.dialog h2 {
  font-size: 1.55rem;
  color: var(--gold);
  margin: 0.2rem 0 0.7rem;
}
.dialog p {
  font-size: 0.83rem;
}
.dialog .action {
  margin-top: 8px;
  background: #ffd76a;
  border: 0;
  color: #1b2a3d;
  padding: 10px 16px;
}
.roundLabel {
  color: var(--pink);
  font-weight: 900;
}
.tiny {
  font-size: 0.65rem;
  color: var(--muted);
}
@media (max-width: 850px) {
  .intro {
    grid-template-columns: 1fr;
  }
  .layout {
    grid-template-columns: 1fr;
  }
  .side {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 9px;
  }
  .side .panel {
    margin: 0;
  }
}
@media (max-width: 560px) {
  .wrap {
    padding: 0 9px;
    margin: 10px auto;
  }
  .panel {
    padding: 10px;
  }
  .side {
    grid-template-columns: 1fr;
  }
  .memory-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 5px;
  }
  .tile {
    height: 72px;
    padding: 3px;
  }
  .faceText {
    font-size: 0.56rem;
  }
  .coord {
    font-size: 0.47rem;
  }
  .top {
    padding: 11px 12px;
  }
  .stats {
    gap: 4px;
  }
}
.dialog-icon {
  display: none !important;
}
