:root {
  font-family: Arial, Helvetica, sans-serif;
  color: #f1f5eb;
  background: #102329;
  --lime: #d6f66c;
  --muted: #b1c2c5;
  --line: #426068;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  min-height: 100dvh;
  background: radial-gradient(ellipse at 90% 30%, #29454a, transparent 65%);
}
button,
a {
  -webkit-tap-highlight-color: transparent;
}
button {
  font: inherit;
  background: #233b42;
  color: #f1f5eb;
  border: 1px solid var(--line);
  padding: 12px 18px;
  border-radius: 12px;
  box-shadow: 0 3px 0 #08171b;
  cursor: pointer;
  touch-action: manipulation;
  transition:
    background 0.15s,
    transform 0.15s;
}
button:hover {
  background: #34555b;
}
button:active {
  transform: translateY(2px);
}
button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--lime);
  outline-offset: 3px;
}
button:disabled {
  cursor: default;
}
header {
  max-width: 1500px;
  margin: auto;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 17px 4vw;
}
.brand img {
  display: block;
  width: 104px;
  height: 66px;
  object-fit: contain;
  background: #fff;
  border-radius: 10px;
  padding: 5px;
}
.event {
  font-size: 10px;
  letter-spacing: 1.5px;
  color: var(--muted);
  line-height: 1.8;
}
.event b {
  color: #fff;
  font-size: 14px;
}
nav {
  display: flex;
  gap: 8px;
  margin-left: auto;
}
nav button {
  font-size: 12px;
  padding: 11px 13px;
}
main {
  max-width: 1440px;
  margin: auto;
  padding: 20px 4vw 25px;
}
.welcome {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 40px;
  align-items: center;
  min-height: calc(100dvh - 210px);
}
h1 {
  font-size: clamp(45px, 6vw, 88px);
  line-height: 0.98;
  letter-spacing: -3px;
  margin: 20px 0;
}
em {
  font-style: normal;
  color: var(--lime);
}
.eyebrow {
  font-weight: 800;
  letter-spacing: 2px;
  font-size: 12px;
  color: var(--lime);
}
p {
  color: var(--muted);
  line-height: 1.5;
}
.lead {
  font-size: 25px;
  color: #fff;
  margin-bottom: 10px;
}
.levels {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 28px 0 15px;
}
.levels button {
  text-align: left;
  padding: 16px 13px;
  min-width: 0;
}
.levels span {
  color: var(--lime);
  font-size: 12px;
}
.levels strong {
  display: block;
  font-size: 24px;
  margin: 10px 0;
}
.levels small {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}
.levels button:first-child {
  background: var(--lime);
  border-color: var(--lime);
  color: #15262a;
}
.levels button:first-child span,
.levels button:first-child small {
  color: #314633;
}
.hint,
#ready,
.connection {
  font-size: 12px;
}
.connection {
  color: var(--lime);
}
.workshops {
  display: grid;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
  margin-top: 25px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}
.workshops b {
  font-size: 10px;
  letter-spacing: 1.5px;
  color: var(--lime);
}
.postcards {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 500px;
  max-height: 65vh;
  min-width: 0;
}
.postcards figure {
  margin: 0;
  width: 42%;
  aspect-ratio: 2/3;
  background: #314a51;
  padding: 7px;
  border: 1px solid #6a888d;
  border-radius: 14px;
  position: absolute;
  box-shadow: 0 18px 36px #07151888;
}
.postcards img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 8px;
}
.postcards figure:nth-child(1) {
  left: 0;
  transform: rotate(-12deg) translateY(25px);
}
.postcards figure:nth-child(2) {
  left: 29%;
  z-index: 2;
  transform: rotate(4deg) translateY(-30px);
}
.postcards figure:nth-child(3) {
  right: 0;
  transform: rotate(15deg) translateY(40px);
}
.photo-note {
  position: absolute;
  bottom: 8px;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 1px;
}
footer {
  max-width: 1500px;
  margin: auto;
  padding: 15px 4vw;
  border-top: 1px solid #355058;
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
}
footer span:first-child {
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--lime);
}
[hidden] {
  display: none !important;
}
body.playing {
  height: 100dvh;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
body.playing header {
  width: 100%;
  flex-shrink: 0;
  padding-top: 8px;
  padding-bottom: 8px;
}
body.playing .brand img {
  height: 43px;
  width: 79px;
}
body.playing main {
  width: 100%;
  flex: 1;
  min-height: 0;
  padding-top: 3px;
  padding-bottom: 0;
  display: flex;
  flex-direction: column;
}
body.playing footer {
  display: none;
}
.game {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
}
.hud {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 6px 3px 11px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.hud > div {
  display: grid;
  gap: 4px;
}
.hud small {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.hud strong {
  font-size: 21px;
  font-variant-numeric: tabular-nums;
}
.hud > div:first-child {
  margin-right: auto;
}
.hud button {
  font-size: 12px;
  padding: 10px;
}
.board-area {
  flex: 1;
  min-height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  padding: 12px 3px;
}
#board {
  display: grid;
  gap: 8px;
  flex-shrink: 0;
}
.card {
  padding: 0;
  position: relative;
  border-radius: 9px;
  border: 1px solid #709394;
  overflow: hidden;
  background: #16343b;
  box-shadow: 0 3px 0 #071519;
  transition:
    transform 0.18s,
    border-color 0.18s;
  min-width: 0;
  min-height: 0;
}
.card img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  visibility: hidden;
}
.card .back {
  position: absolute;
  inset: 5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px solid #608383;
  border-radius: 5px;
  background: repeating-linear-gradient(
    135deg,
    transparent,
    transparent 10px,
    #52747719 10px,
    #52747719 11px
  );
  font-weight: 800;
  letter-spacing: 1px;
  font-size: clamp(7px, 1.1vw, 15px);
  color: #daefc5;
  pointer-events: none;
}
.back .symbol {
  font-size: clamp(17px, 2.5vw, 38px);
  font-weight: 400;
  margin-bottom: 6px;
  color: var(--lime);
}
.back small {
  font-size: 0.55em;
  margin-top: 4px;
  letter-spacing: 2px;
}
.card.open img,
.card.matched img {
  visibility: visible;
}
.card.open .back,
.card.matched .back {
  display: none;
}
.card.open {
  border-color: #d0e1d6;
}
.card.matched {
  border: 2px solid var(--lime);
  box-shadow: 0 0 0 1px #d6f66c33;
}
.card.matched:after {
  content: "✓";
  position: absolute;
  right: 4px;
  bottom: 4px;
  border-radius: 50%;
  background: var(--lime);
  color: #19392a;
  width: 20px;
  height: 20px;
  font-size: 12px;
  line-height: 20px;
  box-shadow: 0 1px 3px #0008;
}
.game-note {
  text-align: center;
  font-size: 12px;
  min-height: 20px;
  margin: 4px 0 10px;
  flex-shrink: 0;
}
.preview {
  position: absolute;
  left: 50%;
  bottom: 38px;
  transform: translateX(-50%);
  padding: 12px 20px;
  border-radius: 30px;
  background: var(--lime);
  color: #203029;
  font-size: 18px;
  font-weight: 800;
  box-shadow: 0 5px 22px #0009;
  pointer-events: none;
}
.result {
  text-align: center;
  max-width: 720px;
  margin: 25px auto;
}
.award {
  font-size: 65px;
  color: var(--lime);
}
h2 {
  font-size: clamp(27px, 4vw, 48px);
  line-height: 1.15;
  letter-spacing: -1px;
}
.result-score {
  display: grid;
  color: var(--lime);
  gap: 4px;
}
.result-score strong {
  font-size: 72px;
  letter-spacing: -3px;
}
.result-score span {
  font-size: 13px;
  letter-spacing: 2px;
}
.actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 25px;
}
.primary {
  background: var(--lime);
  color: #1a2d24;
  border-color: var(--lime);
  font-weight: 800;
}
.primary:hover {
  background: #e5ff9a;
}
dialog {
  border: 1px solid #64888c;
  border-radius: 20px;
  background: #203a41;
  color: white;
  max-width: min(90vw, 500px);
  padding: 28px;
}
dialog h2 {
  font-size: 27px;
}
dialog::backdrop {
  background: #001019b0;
}
#toast {
  position: fixed;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: #edf6d9;
  color: #1b302a;
  border-radius: 10px;
  padding: 12px 18px;
  max-width: 90vw;
  z-index: 5;
  text-align: center;
  font-size: 13px;
}
@media (max-width: 740px) {
  header {
    padding: 12px 4%;
    gap: 8px;
  }
  .brand img {
    width: 83px;
    height: 54px;
  }
  .event {
    display: none;
  }
  nav {
    gap: 5px;
  }
  nav button {
    font-size: 10px;
    padding: 10px 8px;
    min-height: 38px;
  }
  main {
    padding-top: 8px;
  }
  .welcome {
    grid-template-columns: 1fr;
    gap: 0;
  }
  .welcome-copy {
    position: relative;
    z-index: 2;
  }
  h1 {
    font-size: 56px;
    letter-spacing: -2px;
  }
  .postcards {
    height: 290px;
    max-height: none;
    max-width: 400px;
    width: 100%;
    margin: 25px auto 15px;
  }
  .postcards figure {
    width: 37%;
    max-height: 260px;
  }
  .postcards figure:nth-child(2) {
    left: 32%;
  }
  .postcards figure:nth-child(3) {
    right: 0;
  }
  .photo-note {
    bottom: -2px;
  }
  .levels {
    gap: 7px;
  }
  .levels button {
    padding: 12px 10px;
  }
  .levels strong {
    font-size: 21px;
  }
  .levels small {
    font-size: 10px;
  }
  .hud {
    gap: 13px;
  }
  .hud strong {
    font-size: 17px;
  }
  .hud small {
    font-size: 9px;
    letter-spacing: 0.5px;
  }
  .hud button {
    font-size: 10px;
    padding: 8px;
  }
  .board-area {
    padding: 9px 0;
  }
  .back small {
    letter-spacing: 1px;
  }
  .game-note {
    font-size: 11px;
  }
  body.playing main {
    padding-left: 3%;
    padding-right: 3%;
  }
  footer {
    font-size: 9px;
  }
  .result-score strong {
    font-size: 60px;
  }
}
@media (max-height: 500px) and (orientation: landscape) {
  header {
    padding: 6px 3%;
  }
  .brand img {
    height: 40px;
    width: 70px;
  }
  .welcome {
    grid-template-columns: 1.2fr 1fr;
    min-height: 0;
    gap: 20px;
  }
  h1 {
    font-size: 44px;
    margin: 10px 0;
  }
  .lead {
    font-size: 18px;
    margin: 8px 0;
  }
  .levels {
    margin: 14px 0 8px;
  }
  .levels strong {
    font-size: 19px;
    margin: 5px 0;
  }
  .postcards {
    height: 260px;
    margin: 0;
    max-height: none;
  }
  .workshops {
    margin-top: 14px;
  }
  .hint {
    margin: 8px 0;
  }
  body.playing header {
    padding: 4px 3%;
  }
  body.playing .brand img {
    height: 34px;
    width: 64px;
  }
  .hud {
    padding: 4px 0 6px;
  }
  .hud strong {
    font-size: 16px;
  }
  .hud small {
    font-size: 9px;
  }
  .hud > div {
    gap: 2px;
  }
  .game-note {
    margin: 1px 0 4px;
    min-height: 15px;
  }
  .board-area {
    padding: 7px 0;
  }
  .preview {
    bottom: 25px;
    padding: 8px 18px;
    font-size: 15px;
  }
  .event {
    display: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}

#scoreForm {
  max-width: 560px;
  margin: 20px auto 0;
  display: grid;
  gap: 8px;
  text-align: left;
}
#scoreForm label {
  font-size: 12px;
  font-weight: 800;
  color: var(--lime);
  letter-spacing: 1px;
  text-transform: uppercase;
}
.save-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}
.save-row input {
  min-width: 0;
  border: 1px solid #607e84;
  border-radius: 11px;
  background: #152b31;
  color: #fff;
  padding: 13px 14px;
  font: inherit;
}
.save-row input:focus {
  outline: 3px solid var(--lime);
  outline-offset: 2px;
}
#scoreForm small {
  color: var(--muted);
  font-size: 11px;
}
.save-status {
  min-height: 24px;
  color: #fff;
  font-weight: 700;
}
.ranking {
  max-width: 1040px;
  margin: 10px auto;
}
.rank-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
}
.rank-head h2 {
  margin: 7px 0 15px;
}
.rank-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 12px 0;
}
.rank-tabs button.active {
  background: var(--lime);
  border-color: var(--lime);
  color: #183029;
  font-weight: 800;
}
#rankStatus {
  font-size: 12px;
}
#leaders {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px 18px;
}
#leaders li {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  background: #20373e;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px;
}
#leaders .place {
  color: var(--lime);
  font-size: 20px;
  font-weight: 800;
}
#leaders .player {
  font-weight: 700;
  overflow-wrap: anywhere;
}
#leaders .mark {
  text-align: right;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
#leaders .mark small {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 400;
  margin-top: 3px;
}
@media (max-width: 740px) {
  .save-row {
    grid-template-columns: 1fr;
  }
  .rank-head {
    align-items: flex-start;
    flex-direction: column;
  }
  .rank-tabs {
    grid-template-columns: 1fr;
  }
  .ranking {
    margin-top: 0;
  }
  #leaders {
    grid-template-columns: 1fr;
  }
}
