:root {
  color-scheme: light;
  --paper: #f3f0e7;
  --ink: #142f47;
  --forest: #315b49;
  --forest-deep: #234636;
  --coral: #e96561;
  --blue: #3987d2;
  --wave: #d1e7ed;
  --leaf: #d9e7d3;
  --sun: #f1e0b8;
  --burnt: #4b4e4c;
  --view-height: var(--visual-height, 100vh);
}

* { box-sizing: border-box; }
html { background: var(--paper); -webkit-text-size-adjust: 100%; }
@supports (height: 100svh) { :root { --view-height: min(100svh, var(--visual-height, 100svh)); } }
/* Keep NinePick's own light palette when the shared puzzle theme is loaded. */
html body {
  --surface: #fffdf8;
  --muted: #5f7383;
  --line: #d7dfdb;
  min-height: var(--view-height);
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 3px solid #3178b6;
  outline-offset: 3px;
}
[hidden] { display: none !important; }
.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  clip-path: inset(50%) !important;
}

.app-shell {
  width: min(460px, 100%);
  min-height: var(--view-height);
  margin: 0 auto;
  padding: max(4px, env(safe-area-inset-top)) 14px max(8px, env(safe-area-inset-bottom));
  --game-room: calc(var(--view-height) - max(4px, env(safe-area-inset-top)) - max(8px, env(safe-area-inset-bottom)));
  --own-board: clamp(148px, calc((var(--game-room) - 330px) / 2), 180px);
  --offer-size: clamp(32px, calc(32px + (var(--game-room) - 556px) * .1), 40px);
  --phase-size: clamp(192px, calc(192px + (var(--game-room) - 556px) * .1), 200px);
  --other-board: clamp(60px, calc((var(--game-room) - 448px) / 2), 164px);
}
.app-header {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid rgba(38, 63, 82, .14);
}
.brand {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
  color: #203d55;
  font-size: 14px;
  font-weight: 750;
  text-decoration: none;
}
.brand b { color: var(--forest); }
.puzzle-home-link {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 6px 10px;
  border: 1px solid rgba(38, 63, 82, .18);
  border-radius: 999px;
  color: #203d55;
  font-size: 12px;
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
}
.puzzle-home-link:hover { background: rgba(38, 63, 82, .06); }
.puzzle-home-link:focus-visible { outline: 3px solid #2563eb; outline-offset: 2px; }
body.is-playing .puzzle-home-link { display: none; }
.brand-mark {
  position: relative;
  display: inline-block;
  width: 20px;
  height: 20px;
  transform: rotate(-12deg);
}
.brand-mark i {
  position: absolute;
  width: 9px;
  height: 9px;
  border: 1px solid rgba(53, 72, 56, .14);
  border-radius: 3px;
}
.brand-mark i:nth-child(1) { top: 1px; left: 1px; background: var(--wave); }
.brand-mark i:nth-child(2) { top: 2px; right: 0; background: #f3d2c9; }
.brand-mark i:nth-child(3) { bottom: 0; left: 5px; background: var(--leaf); }
.header-actions {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}
.network-badge {
  max-width: 150px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.network-badge::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 6px;
  border-radius: 50%;
  background: #a6b0a7;
  vertical-align: 1px;
}
.network-badge.is-online::before { background: #5a9566; }
.network-badge.is-waiting::before { background: #d2a34f; }
.network-badge.is-offline::before { background: #ce7467; }
.round-label { flex: 0 0 auto; color: var(--ink); font-size: 14px; white-space: nowrap; }
.mode-label {
  max-width: 72px;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.icon-button {
  width: 44px;
  height: 44px;
  display: inline-grid;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: #38536a;
  font-size: 18px;
  cursor: pointer;
}
.effect-sound-button { width: 44px; height: 44px; color: #617566; font-size: 19px; }
.effect-sound-button.is-sound-on { border-color: #94b49b; background: #edf5eb; color: #315b49; }
.text-button {
  min-height: 44px;
  padding: 8px 10px;
  border: 0;
  background: transparent;
  color: #5e7383;
  font-size: 14px;
  cursor: pointer;
}
.text-button:hover { color: var(--ink); text-decoration: underline; }
.header-leave { flex: 0 0 auto; padding-right: 3px; padding-left: 3px; font-size: 12px; }

.screen { padding: 18px 0 8px; }
h1, h2, h3, p { overflow-wrap: anywhere; }
.eyebrow { margin: 0 0 6px; color: #718596; font-size: 12px; font-weight: 700; letter-spacing: .045em; }
.intro { padding: 10px 3px 12px; }
.intro h1, .waiting-screen h1, .finished-screen h1 {
  margin: 0;
  color: #1b3851;
  font-size: clamp(28px, 8vw, 38px);
  line-height: 1.18;
  letter-spacing: -.055em;
}
.intro h1 span { color: #547a67; }
.intro > p:not(.eyebrow):not(.lobby-rule-note), .waiting-copy {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}
.lobby-rule-note {
  margin-top: 9px;
  padding: 8px 10px;
  border: 1px solid #dce5db;
  border-radius: 10px;
  background: #f8f7ef;
  color: #526d5d;
  font-size: 12px;
  line-height: 1.4;
}
.field-label { display: block; margin: 0 0 6px; color: #556e80; font-size: 13px; font-weight: 700; }
.text-input {
  width: 100%;
  min-width: 0;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid #d7e0e0;
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font-size: 16px;
}
.text-input::placeholder { color: #8c9ba4; }
.name-input { margin-bottom: 12px; }

.button {
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 14px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 700;
  text-align: center;
  cursor: pointer;
  box-shadow: 0 2px 0 rgba(22, 50, 69, .14);
  transition: background-color .15s ease, border-color .15s ease, transform .15s ease, box-shadow .15s ease;
}
.button:active:not(:disabled) { transform: translateY(1px); box-shadow: 0 1px 0 rgba(22, 50, 69, .14); }
.button:disabled { cursor: not-allowed; opacity: 1; }
.button[aria-busy="true"] { cursor: progress; }
.button[aria-busy="true"]::before {
  width: 13px;
  height: 13px;
  content: "";
  flex: 0 0 auto;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: button-spin .75s linear infinite;
}
@keyframes button-spin { to { transform: rotate(360deg); } }
.button-primary { background: var(--forest); color: #fff; }
.button-primary:hover:not(:disabled) { background: var(--forest-deep); }
.button-primary:disabled { background: #61796d; color: #fff; }
.button-secondary { border-color: #d5e0df; background: #fffdf8; color: #3f5c6d; }
.button-secondary:hover:not(:disabled) { border-color: #9eb7b0; background: #f6faf5; }
.button-secondary:disabled { background: #eeeee8; color: #526574; }
.button-destructive { background: #a84645; color: #fff; }
.button-destructive:hover { background: #873b3b; }
#createOnline { width: 100%; }
.join-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.code-input { text-transform: uppercase; letter-spacing: .1em; }
.join-form { margin: 0; }
.join-form .field-label { margin-bottom: 6px; }
.field-hint, .field-message { margin: 6px 2px 0; font-size: 12px; line-height: 1.4; }
.field-hint { color: #718392; }
.field-message { color: #526b7d; }
.field-message:empty { display: none; }
.field-message.is-error { color: #a84047; }
.code-input[aria-invalid="true"] { border-color: #b95755; box-shadow: 0 0 0 2px rgba(185, 87, 85, .12); }

.screen-message:empty { display: none; }
.screen-message { min-height: 20px; margin: 12px 2px 0; color: #536b7c; font-size: 13px; line-height: 1.45; }

.waiting-screen { padding-top: 30px; text-align: center; }
.waiting-screen .eyebrow { margin-bottom: 8px; }
.waiting-screen h1, .finished-screen h1 { font-size: 30px; }
.invite-code-box {
  display: grid;
  justify-items: center;
  gap: 8px;
  margin: 22px 0 16px;
  padding: 18px 14px;
  border: 1px solid #d5e1df;
  border-radius: 17px;
  background: var(--surface);
}
.invite-code-box .field-label { margin: 0; }
.invite-code-box > strong { color: var(--forest-deep); font-size: 30px; letter-spacing: .16em; }
.invite-copy-actions { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.invite-copy-actions .button { min-width: 0; padding-right: 8px; padding-left: 8px; }
.room-seat-list { display: grid; gap: 7px; margin: 0; padding: 0; list-style: none; text-align: left; }
.room-seat {
  min-height: 48px;
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 7px 11px;
  border-bottom: 1px solid #e1e6e2;
  font-size: 14px;
}
.seat-dot { width: 9px; height: 9px; border-radius: 50%; background: #a4ada4; }
.seat-dot--you { background: var(--blue); }
.seat-status { color: #718493; font-size: 12px; white-space: nowrap; }
.seat-status.is-connected { color: #47775d; }
.waiting-screen > .text-button { margin-top: 14px; }

.game-screen { display: grid; gap: 2px; padding: 1px 0; }
.goal-strip {
  min-height: 46px;
  display: grid;
  gap: 3px;
  padding: 5px 10px;
  border: 1px solid #e1e5db;
  border-radius: 12px;
  background: #faf8f0;
}
.goal-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.goal-heading strong { color: #213c54; font-size: 13px; line-height: 16px; }
.goal-description {
  margin: 0;
  color: #425e70;
  font-size: 12px;
  line-height: 16px;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
.goal-award { flex: 0 0 auto; color: #786744; font-size: 11px; white-space: nowrap; }
.goal-strip { position: relative; overflow: hidden; }
.goal-strip.is-goal-pop { animation: goal-complete-pop .6s cubic-bezier(.2,.75,.2,1) both; }
.goal-strip.is-goal-pop::after { content: ""; position: absolute; inset: -35%; pointer-events: none; opacity: 0; background: radial-gradient(circle at 13% 54%, #e3b852 0 2px, transparent 3px), radial-gradient(circle at 28% 19%, #f4d789 0 2px, transparent 3px), radial-gradient(circle at 48% 9%, #dbb458 0 2px, transparent 3px), radial-gradient(circle at 74% 16%, #eed18b 0 2px, transparent 3px), radial-gradient(circle at 89% 51%, #d8a743 0 2px, transparent 3px), radial-gradient(circle at 69% 82%, #edce7d 0 2px, transparent 3px), radial-gradient(ellipse at 50% 50%, rgba(255,232,160,.28), transparent 64%); animation: goal-sparkle .6s ease-out both; }

.board-section { display: grid; justify-items: center; }
.board-heading {
  width: min(100%, 260px);
  min-height: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.seat-heading { min-width: 0; display: flex; align-items: center; gap: 5px; }
.seat-heading h2 { min-width: 0; overflow: hidden; margin: 0; color: #345369; font-size: 12px; font-weight: 700; line-height: 1.2; text-overflow: ellipsis; white-space: nowrap; }
.seat-heading .seat-status { flex: 0 0 auto; color: #718493; font-size: 10px; }
.seat-heading .seat-status::before { content: ""; display: inline-block; width: 5px; height: 5px; margin-right: 3px; border-radius: 50%; background: #a4ada4; }
.seat-heading .seat-status.is-connected::before { background: #5a9566; }
.seat-heading .seat-status--self::before { background: var(--blue); }
.score-cluster { flex: 0 0 auto; display: flex; align-items: baseline; gap: 5px; white-space: nowrap; }
.score-cluster > strong { color: #24445b; font-size: 16px; line-height: 1; }
.score-cluster > strong span { margin-left: 1px; color: #667d8d; font-size: 10px; font-weight: 500; }
.score-breakdown { color: #718493; font-size: 10px; }
.board-grid {
  width: min(100%, var(--own-board));
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(0, 1fr));
  gap: 3px;
  margin: 0 auto;
  padding: 4px;
  border: 1px solid #d3dbd5;
  border-radius: 12px;
  background: #e9e9df;
  box-shadow: inset 0 2px 4px rgba(28, 48, 56, .08), 0 2px 5px rgba(34, 51, 58, .08);
}
.opponent-section .board-grid { width: min(100%, var(--other-board)); }
.opponent-section .board-cell { min-width: 0; min-height: 0; }
.board-cell {
  min-width: 44px;
  min-height: 44px;
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 1px;
  border: 1px solid #d9e0db;
  border-radius: 8px;
  background: #faf9f4;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .86), 0 1px 2px rgba(26, 48, 57, .08);
  cursor: default;
}
.board-cell.is-empty { background: rgba(255, 253, 247, .7); }
.board-cell.is-placeable { border-style: dashed; cursor: pointer; }
.board-cell.is-placeable:hover, .board-cell.is-placeable:focus-visible { border-color: var(--blue); background: #f2f8fc; }
.board-cell.is-selected { z-index: 1; border: 3px solid #246faf; background: #eff7ff; box-shadow: none; }
.board-cell.is-selected .tile-art { inset: 3px; width: calc(100% - 6px); height: calc(100% - 6px); }
.board-cell.is-scored { border-color: #6d9b7b; box-shadow: inset 0 0 0 1px #6d9b7b; }
.board-cell.is-new-score { border-color: #d2a851; box-shadow: inset 0 0 0 2px #d2a851; }
.board-cell.is-burnt { background: #565a58; }
.board-cell.is-pattern-hit { z-index: 2; animation: pattern-cell-pop .53s cubic-bezier(.2,.75,.25,1) both; }
.board-cell.is-pattern-hit .tile-art { animation: pattern-art-pop .53s cubic-bezier(.2,.75,.25,1) both; }
.score-cluster > strong { position: relative; }
.score-cluster > strong.is-score-pop { animation: score-credit-pop .2s ease-out both; transform-origin: center; }
img[data-tile-icon] { border-radius: 18%; }
img[data-tile-icon="coral"] { background: #fff0eb; }
img[data-tile-icon="blue"] { background: #e7f5ff; }
img[data-tile-icon="green"] { background: #ebf8e8; }
img[data-tile-icon="gold"] { background: #fff7de; }
.tile-art { position: absolute; inset: 1px; width: calc(100% - 2px); height: calc(100% - 2px); display: block; object-fit: contain; pointer-events: none; }
.cell-empty-mark { color: #b9c4c4; font-size: 18px; line-height: 1; }

@keyframes pattern-cell-pop { 0% { transform: scale(.96); border-color: #d2a851; box-shadow: inset 0 0 0 2px #d2a851, 0 0 0 0 rgba(218,174,76,0); } 38% { transform: scale(1.055); box-shadow: inset 0 0 0 2px #e3bd62, 0 0 0 5px rgba(218,174,76,.18); } 100% { transform: scale(1); border-color: #d2a851; box-shadow: inset 0 0 0 1px #d2a851; } }
@keyframes pattern-art-pop { 0% { transform: scale(.96); } 42% { transform: scale(1.09); } 100% { transform: scale(1); } }
@keyframes score-credit-pop { 0% { transform: scale(1); color: #24445b; } 36% { transform: scale(1.24); color: #b27e24; text-shadow: 0 2px 12px rgba(213,174,82,.36); } 100% { transform: scale(1); color: #24445b; text-shadow: none; } }
@keyframes goal-complete-pop { 0% { transform: scale(1); } 18% { transform: scale(.975); border-color: #d4ad54; } 48% { transform: scale(1.025); background-color: #fff9e8; box-shadow: 0 0 0 3px rgba(224,190,105,.2); } 100% { transform: scale(1); border-color: #e1e5db; box-shadow: none; background-color: #faf8f0; } }
@keyframes goal-sparkle { 0% { opacity: 0; transform: scale(.8) rotate(-8deg); } 23% { opacity: 1; } 100% { opacity: 0; transform: scale(1.1) rotate(8deg); } }
@keyframes collision-card-pulse { 0% { transform: scale(1); } 18% { transform: scale(1.08); } 31% { transform: translateX(-2px); } 42% { transform: translateX(2px); } 53% { transform: translateX(-1px); } 100% { transform: translateX(0) scale(1); border-color: #bd534c; } }
@keyframes card-scorch { 0%, 18% { filter: none; } 44% { filter: sepia(.8) saturate(1.5) brightness(.78); } 80%,100% { filter: sepia(1) saturate(.4) brightness(.3); } }
@keyframes collision-ghost-dissolve { 0%,18% { clip-path: polygon(0 0,100% 0,100% 100%,89% 100%,76% 100%,63% 100%,49% 100%,36% 100%,21% 100%,8% 100%,0 100%); opacity: 1; transform: translate(-50%,-50%); } 35% { clip-path: polygon(0 0,100% 0,100% 77%,89% 66%,76% 83%,63% 70%,49% 78%,36% 64%,21% 81%,8% 69%,0 75%); } 50% { clip-path: polygon(0 0,100% 0,100% 52%,89% 37%,76% 58%,63% 43%,49% 50%,36% 34%,21% 55%,8% 40%,0 48%); } 65% { clip-path: polygon(0 0,100% 0,100% 25%,89% 13%,76% 34%,63% 18%,49% 26%,36% 9%,21% 31%,8% 16%,0 22%); } 80%,100% { clip-path: polygon(0 0,100% 0,100% 0,89% 0,76% 0,63% 0,49% 0,36% 0,21% 0,8% 0,0 0); opacity: 1; } }
@keyframes burn-card-reveal { 0% { transform: scale(.97); border-color: #e8dbd2; } 38% { transform: scale(1.055); background-color: #fff0e8; border-color: #bd534c; } 100% { transform: scale(1); background-color: #faf0e9; border-color: #e8dbd2; } }
@keyframes burn-content-reveal { 0%,60% { opacity: 0; transform: scale(.96); } 80% { opacity: 1; transform: scale(1.04); } 100% { opacity: 1; transform: scale(1); } }
@keyframes collision-embers { 0% { opacity: 0; transform: translate(-50%,-50%) scale(.7); } 20% { opacity: .85; } 100% { opacity: 0; transform: translate(-50%,-74%) scale(1.25); } }
@keyframes collision-flame { 0% { opacity: 0; transform: translate(-50%,0) scale(.4) rotate(-12deg); } 20% { opacity: 1; } 100% { opacity: 0; transform: translate(calc(-50% + var(--particle-drift)), -48px) scale(.15) rotate(24deg); } }
@keyframes collision-ember-flight { 0% { opacity: 0; transform: translate(-50%,0) scale(.4); } 18% { opacity: 1; } 100% { opacity: 0; transform: translate(calc(-50% + var(--particle-drift)), -54px) scale(.1); } }
@keyframes collision-ash-flight { 0% { opacity: 0; transform: translate(-50%,0) rotate(0) scale(.5); } 18% { opacity: .9; } 100% { opacity: 0; transform: translate(calc(-50% + var(--particle-drift)), -38px) rotate(170deg) scale(.25); } }
@keyframes collision-glint { 0% { opacity: 0; transform: translate(-50%,0) scale(.25) rotate(0); } 28% { opacity: 1; transform: translate(-50%,-8px) scale(1) rotate(40deg); } 100% { opacity: 0; transform: translate(calc(-50% + var(--particle-drift)), -35px) scale(.2) rotate(90deg); } }
@keyframes collision-edge-flicker { 0%, 100% { opacity: .3; } 50% { opacity: 1; } }
@keyframes scorch-flash { 0% { opacity: 0; transform: translateX(-40%) skewX(-18deg); } 18% { opacity: .95; } 100% { opacity: 0; transform: translateX(50%) skewX(-18deg); } }
@media (prefers-reduced-motion: reduce) { .goal-strip.is-goal-pop, .goal-strip.is-goal-pop::after, .board-cell.is-pattern-hit, .board-cell.is-pattern-hit .tile-art, .score-cluster > strong.is-score-pop, .score-cluster > strong.is-score-pop::after, .offer-card.is-collision-ghost, .offer-card.is-collision-ghost img, .received-card.is-burn-reveal, .received-card.is-burn-reveal img, .phase-panel.collision-embers::after, .collision-particle { animation: none !important; } }

.phase-panel {
  min-height: var(--phase-size);
  position: relative;
  display: grid;
  grid-template-rows: 18px 1fr 18px;
  row-gap: 4px;
  padding: 12px 16px;
  border: 1px solid #e1e3dc;
  border-radius: 20px;
  background: #fffdf8;
}
.phase-ring { position: absolute; z-index: 0; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.phase-ring path { fill: none; vector-effect: non-scaling-stroke; stroke-width: 2px; }
.phase-ring-track { stroke: #d9dedb; }
.phase-ring-progress { stroke-linecap: round; stroke-dasharray: 100 100; transition: stroke-dasharray .2s linear; }
.phase-ring-progress--opponent { stroke: var(--coral); }
.phase-ring-progress--player { stroke: var(--blue); }
.phase-panel.is-settled { grid-template-rows: 1fr; }
.phase-panel.is-settled .phase-ring-progress { stroke: #c2ccc9; stroke-dasharray: 0 100 !important; }
.phase-timer {
  min-width: 0;
  position: relative;
  z-index: 1;
  min-height: 18px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 2px;
  font-size: 10px;
  font-weight: 700;
}
.phase-timer--opponent { color: #c4484c; }
.phase-timer--player { color: #226dae; }
.timer-readout {
  min-width: 30px;
  min-height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 1px 4px;
  border: 1px solid currentColor;
  border-radius: 999px;
  background: #fffdf8;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.phase-timer--opponent .timer-readout { background: #fff4f0; }
.phase-timer--player .timer-readout { background: #f0f7fc; }
.phase-panel.is-critical { border-color: #b52e35; background: #fff5ef; box-shadow: 0 0 0 2px rgba(181, 46, 53, .2); }
.phase-panel.is-critical .phase-ring-progress--player { stroke: #b52e35; stroke-width: 3px; }
.phase-timer.is-critical .timer-readout { min-width: 38px; color: #fff; border-color: #b52e35; background: #b52e35; font-size: 14px; font-weight: 800; }
.phase-timer--player.is-critical .timer-readout { animation: countdown-pulse 1s ease-in-out infinite; }
.phase-timer--player.is-critical .ready-label { color: #a1242c; font-weight: 800; }
.phase-panel.is-critical .confirm-button:enabled { --confirm-fill: #b52e35; --confirm-border: #b52e35; }
@keyframes countdown-pulse {
  0%, 100% { transform: scale(1.05); }
  50% { transform: scale(1.2); }
}
.ready-label {
  min-width: 0;
  max-width: 58%;
  overflow: hidden;
  margin-left: auto;
  color: #64798a;
  font-size: 11px;
  font-weight: 500;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.phase-content {
  min-width: 0;
  width: min(264px, 100%);
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-self: center;
  justify-items: center;
  align-content: center;
  gap: 4px;
  text-align: center;
}
.phase-heading { width: 100%; min-height: 18px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.phase-content h2 { flex: 0 0 auto; margin: 0; color: #183650; font-size: 14px; line-height: 18px; }
.phase-content h2:focus, h1[tabindex="-1"]:focus { outline: none; }
.phase-panel.is-collision .phase-content h2 { color: #984e4a; }
.phase-panel.collision-embers::after { content: ""; position: absolute; z-index: 3; left: 50%; top: 52%; width: min(220px, 72%); height: 80px; transform: translate(-50%, -50%); pointer-events: none; opacity: 0; background: radial-gradient(circle at 8% 68%, #f4a36b 0 2px, transparent 3px), radial-gradient(circle at 19% 23%, #ffd08b 0 1.5px, transparent 2.5px), radial-gradient(circle at 38% 82%, #e68b58 0 2px, transparent 3px), radial-gradient(circle at 67% 18%, #ffc57d 0 2px, transparent 3px), radial-gradient(circle at 91% 70%, #ed9160 0 2px, transparent 3px); animation: collision-embers .82s ease-out both; }
.collision-particle { position: absolute; z-index: 6; left: var(--particle-x); top: 53%; display: block; pointer-events: none; will-change: transform, opacity; animation-delay: var(--particle-delay); }
.collision-particle--flame { width: 6px; height: 13px; border-radius: 70% 20% 65% 35%; background: linear-gradient(0deg, #e96b42, #ffd179 72%, #fff1c3); box-shadow: 0 0 8px rgba(245,121,63,.72); animation: collision-flame 420ms ease-out both; }
.collision-particle--ember { width: 4px; height: 4px; border-radius: 50%; background: #ffc478; box-shadow: 0 0 8px 2px rgba(246,127,65,.66); animation: collision-ember-flight 480ms ease-out both; }
.collision-particle--ash { width: 4px; height: 3px; border-radius: 1px; background: #77736c; box-shadow: 0 0 3px rgba(73,67,61,.3); animation: collision-ash-flight 620ms ease-out both; }
.collision-particle--glint { width: 8px; height: 8px; background: #fff0b7; filter: drop-shadow(0 0 4px #ffd575); clip-path: polygon(50% 0,61% 38%,100% 50%,61% 61%,50% 100%,39% 61%,0 50%,39% 39%); animation: collision-glint 360ms ease-out both; }
.collision-particle[class] { animation-delay: var(--particle-delay); }
.offer-card.is-collision-ghost { position: absolute; z-index: 4; left: 50%; top: 44%; width: 76px; min-height: calc(var(--offer-size) + 20px); border-color: #bd534c; background: #fff8f0; box-shadow: 0 0 0 1px rgba(192,74,65,.35), 0 3px 10px rgba(151,54,47,.16); transform: translate(-50%, -50%); pointer-events: none; animation: collision-ghost-dissolve .82s linear both; }
.offer-card.is-collision-ghost::before { content: ""; position: absolute; z-index: -1; inset: -4px; border: 2px solid rgba(210,76,60,.76); border-radius: inherit; box-shadow: 0 0 13px 3px rgba(226,103,58,.36); animation: collision-edge-flicker 420ms steps(2,end) 2 both; }
.offer-card.is-collision-ghost::after { content: ""; position: absolute; z-index: 2; left: 0; right: 0; top: 98%; height: 2px; background: #ffd98f; box-shadow: 0 -1px 4px #ed7847, 0 1px 4px #ffb46b; animation: burn-heat-front .82s linear both; }
.offer-card.is-collision-ghost img { animation: card-scorch .82s linear both; }
.received-card.is-burn-reveal { position: relative; overflow: hidden; border-color: #b85e51; box-shadow: inset 0 0 0 1px rgba(178,66,54,.28); animation: burn-card-reveal .82s cubic-bezier(.2,.75,.2,1) both; }
.received-card.is-burn-reveal img { animation: burn-content-reveal .82s ease-out both; }
.phase-help {
  margin: 0;
  max-width: 100%;
  color: #596f7e;
  font-size: 11px;
  line-height: 14px;
  text-align: right;
}
.phase-panel.is-collision .phase-help {
  color: #8c4847;
}
.offer-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  justify-items: center;
  gap: 8px;
  margin: 0;
  padding-top: 0;
}
.offer-card:focus-visible { outline-width: 2px; outline-offset: 1px; }
.offer-card {
  width: 100%;
  min-width: 0;
  min-height: calc(var(--offer-size) + 20px);
  position: relative;
  display: grid;
  grid-template-rows: var(--offer-size) auto;
  justify-items: center;
  align-content: center;
  gap: 2px;
  padding: 2px;
  border: 1px solid #e1e6dd;
  border-radius: 10px;
  background: #f7f8f1;
  color: var(--ink);
  cursor: pointer;
  transition: background-color .16s ease, border-color .16s ease;
}
.offer-card:hover:not(:disabled) { background: rgba(49, 90, 73, .07); }
.offer-card:disabled { cursor: default; }
.offer-card.is-selected { border-color: var(--forest); background: #eaf2eb; box-shadow: inset 0 0 0 1px var(--forest); }
.offer-card img {
  width: var(--offer-size);
  height: var(--offer-size);
  object-fit: contain;
  transition: filter .22s ease, transform .22s cubic-bezier(.2,.8,.2,1);
}
.offer-card:hover:not(:disabled) img { transform: translateY(-1px) rotate(-1deg); }
.offer-card.is-selected img { filter: drop-shadow(0 2px 2px rgba(25, 50, 65, .18)); }
.offer-card strong { font-size: 11px; line-height: 12px; }
.offer-check {
  position: absolute;
  top: 3px;
  right: 3px;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  width: 16px;
  height: 16px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--forest);
}
.confirm-button {
  --confirm-fill: var(--forest);
  --confirm-border: transparent;
  width: fit-content;
  max-width: 100%;
  min-width: 44px;
  min-height: 44px;
  position: relative;
  isolation: isolate;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  line-height: 20px;
  justify-self: center;
  cursor: pointer;
}
/* The painted surface is 32px tall; the real button retains its 44px hit area. */
.confirm-button::after {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 6px 0;
  border: 1px solid var(--confirm-border);
  border-radius: 8px;
  background: var(--confirm-fill);
  pointer-events: none;
}
.confirm-button:hover:not(:disabled) { --confirm-fill: var(--forest-deep); }
.confirm-button:disabled { --confirm-fill: #f0f2ed; --confirm-border: #d7dfdb; color: #526574; cursor: default; }
.confirm-button.is-confirmed { --confirm-fill: #e8f1e9; --confirm-border: #b6cabb; color: #315b49; }
.confirm-button.is-submitting { --confirm-fill: #456b57; color: #fff; cursor: progress; }
.confirm-button[aria-busy="true"]::before {
  content: "";
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: button-spin .75s linear infinite;
}
.phase-message { max-width: 100%; margin: 0; color: #607789; font-size: 12px; line-height: 1.35; }
.phase-message:empty { display: none; }
.phase-message.is-error { color: #a84047; }
.received-cards {
  min-height: calc(var(--offer-size) + 20px);
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 0;
}
.received-card { width: 100%; min-height: calc(var(--offer-size) + 20px); display: grid; grid-template-columns: var(--offer-size) 1fr; grid-template-rows: 16px 20px; align-content: center; align-items: center; justify-items: start; gap: 0 5px; padding: 4px 6px; border: 1px solid #d9e3d7; border-radius: 10px; background: #f1f6ec; color: #315a49; }
.received-card img { width: var(--offer-size); height: var(--offer-size); grid-column: 1; grid-row: 1 / 3; object-fit: contain; filter: drop-shadow(0 2px 2px rgba(25, 50, 65, .12)); }
.received-card strong { grid-column: 2; grid-row: 2; font-size: 12px; }
.received-label { grid-column: 2; grid-row: 1; color: #667d8d; font-size: 10px; }
.received-card--opponent { border-color: #e8dbd2; background: #faf0e9; color: #756344; }
.received-divider { color: #a6afa6; font-size: 18px; }

.next-row {
  min-height: 22px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 4px;
  border-bottom: 1px solid #dce3df;
}
.next-row > span { flex: 0 0 auto; color: #425f72; font-size: 13px; font-weight: 700; }
.next-offer-grid { min-width: 0; display: flex; flex-wrap: wrap; gap: 7px; }
.next-card { display: inline-flex; align-items: center; gap: 4px; color: #4e6879; font-size: 12px; white-space: nowrap; }
.next-card img { width: 22px; height: 22px; }
.muted { color: #738797; font-size: 13px; }

@media (max-height: 600px) {
  .game-screen { gap: 1px; padding: 0; }
  .next-row { min-height: 20px; }
  .next-card img { width: 18px; height: 18px; }
}

.history-disclosure { border-top: 1px solid #dce3df; }
.history-disclosure > summary {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #425f72;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}
.history-disclosure > summary::-webkit-details-marker { display: none; }
.history-summary-label { flex: 0 0 auto; }
.history-recent {
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  margin: 0 8px;
  color: #607789;
  font-size: 12px;
  font-weight: 500;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.history-disclosure summary small { margin-left: 5px; color: #8192a0; font-size: 12px; font-weight: 400; }
.disclosure-mark { font-size: 17px; font-weight: 400; }
.history-disclosure[open] .disclosure-mark { transform: rotate(45deg); }
.history-list { display: grid; gap: 7px; margin: 0; padding: 0 0 10px 24px; color: #425f72; }
.history-item { padding: 9px 10px; border-left: 2px solid #c9d9d2; background: rgba(255, 253, 247, .72); font-size: 13px; line-height: 1.45; }
.history-item strong { display: block; margin-bottom: 2px; font-size: 14px; }
.history-meta { color: #6c8090; font-size: 12px; }
.history-meta--sides { display: grid; gap: 3px; }
.history-side { overflow-wrap: anywhere; }

.finished-screen { padding-top: 30px; text-align: center; }
.finished-screen > .eyebrow { margin-bottom: 8px; }
.finished-screen h1 { font-size: 30px; }
.winner-message { margin: 9px 0 20px; color: #5d7384; font-size: 15px; }
.final-score-row {
  display: grid;
  grid-template-columns: 1fr 25px 1fr;
  align-items: center;
  gap: 8px;
  padding: 18px 10px;
  border: 1px solid #d9e2df;
  border-radius: 16px;
  background: var(--surface);
}
.final-score-row > div { display: grid; gap: 4px; }
.final-score-row > div > span { color: #536f80; font-size: 14px; }
.final-score-row strong { color: #244f47; font-size: 30px; }
.final-score-row small { color: #738797; font-size: 12px; }
.final-divider { color: #8ba0ab; font-size: 20px; }
.rematch-status { min-height: 22px; margin: 12px 0 5px; color: #61798a; font-size: 13px; }
.rematch-status.is-error { color: #a84047; }
#rematchButton:disabled { border-color: #d7dfdb; background: #ecefea; color: #526574; box-shadow: none; }
.finished-screen > .button, .finished-screen > .text-button { width: 100%; margin-top: 8px; }
.final-boards { display: grid; gap: 14px; margin-top: 16px; }
.final-board-block { display: grid; justify-items: center; gap: 3px; }
.final-board-block .board-heading { display: flex; justify-content: center; width: min(100%, 232px); min-height: 24px; }
.final-board-block .board-heading h2 { margin: 0; color: #28435a; font-size: 14px; }
.final-board-block .board-grid { width: min(100%, 190px); }
.final-history-disclosure { margin-top: 12px; text-align: left; }

.app-footer { display: flex; justify-content: space-between; gap: 8px; padding: 14px 2px 4px; color: #7c909c; font-size: 11px; }
body.is-playing .app-footer, body.is-tutorial .app-footer { display: none; }

.rules-dialog {
  width: min(460px, calc(100% - 28px));
  max-height: min(80vh, 620px);
  padding: 18px;
  border: 1px solid #d3dfdc;
  border-radius: 16px;
  background: var(--surface);
  color: var(--ink);
}
.rules-dialog::backdrop { background: rgba(25, 48, 67, .4); }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.dialog-heading h2 { margin: 0; font-size: 19px; }
.rules-dialog ol { display: grid; gap: 10px; padding-left: 23px; color: #425e70; font-size: 14px; line-height: 1.55; }
.rules-dialog > p { margin: 12px 0 0; color: #607789; font-size: 13px; line-height: 1.5; }
.rules-dialog > .rules-current-goal { padding: 10px 11px; border-radius: 9px; background: #f3f5ed; color: #3e5c4d; }
.rules-dialog > .dialog-note { color: #8c594d; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 18px; }
.dialog-actions .button { min-width: 0; padding-right: 9px; padding-left: 9px; }

@media (min-width: 700px) {
  .app-shell { padding-top: 12px; }
  .screen { padding-top: 20px; }
  .game-screen { padding-top: 6px; gap: 6px; }
  .phase-panel { min-height: 200px; padding-right: 20px; padding-left: 20px; }
}
@media (max-width: 360px) {
  .app-shell { padding-right: 8px; padding-left: 8px; }
  .brand { font-size: 12px; gap: 4px; }
  .brand-mark { display: none; }
  .header-actions { gap: 0; }
  .round-label { font-size: 12px; }
  .goal-strip { padding-right: 8px; padding-left: 8px; }
  .goal-heading strong { font-size: 12px; }
  .goal-award { font-size: 10px; }
  .score-breakdown { font-size: 9px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
  }
  .button[aria-busy="true"]::before, .confirm-button[aria-busy="true"]::before { animation: none; }
  .phase-timer--player.is-critical .timer-readout { animation: none; }
}

.lobby-page { max-width: 360px; margin: 0 auto; }
.lobby-art { display: flex; justify-content: center; gap: 8px; padding: 4px 0 18px; }
.lobby-art img { width: 50px; height: 50px; object-fit: contain; }
.lobby-art img:nth-child(2n) { transform: translateY(6px) rotate(5deg); }
.lobby-art img:nth-child(2n + 1) { transform: rotate(-5deg); }
.menu-stack { display: grid; gap: 8px; }
.menu-button { width: 100%; min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border: 1px solid #cfdbd3; border-radius: 13px; background: var(--surface); color: var(--forest-deep); text-align: left; cursor: pointer; }
.menu-button > span:first-child { display: grid; gap: 4px; }
.menu-button strong { font-size: 17px; }
.menu-button small { color: var(--muted); font-size: 12px; line-height: 1.4; }
.menu-button > span:last-child { font-size: 20px; }
.menu-button:hover { background: #eef4ec; border-color: #8ea997; }
.menu-button:active { transform: translateY(1px); }
.menu-button:disabled { opacity: .65; cursor: progress; }
.menu-button--quiet { background: transparent; border-color: var(--line); }
.page-intro { padding: 18px 2px 24px; }
.online-name-field { max-width: 360px; margin: 0 auto; }
.page-intro h1, .tutorial-heading h1 { margin: 0; font-size: 28px; letter-spacing: -.04em; }
.page-intro > p:last-child { margin: 8px 0 0; color: var(--muted); font-size: 14px; }
.back-button { display: block; width: 100%; margin: 16px auto 0; }
.or-divider { display: flex; align-items: center; gap: 12px; margin: 22px 0 16px; color: var(--muted); font-size: 12px; }
.or-divider::before, .or-divider::after { content: ""; height: 1px; flex: 1; background: var(--line); }
.game-recent { color: var(--muted); font-size: 12px; }
#historyDialog .history-list { margin-top: 12px; }
#historyTitle small { color: var(--muted); font-size: 12px; }
body.is-playing .app-shell { min-height: var(--view-height); }
body.is-playing .icon-button { border-color: transparent; }
body.is-playing .brand-mark { display: none; }
body.is-playing .brand { font-size: 12px; }
body.is-playing .header-actions { gap: 2px; }
.tutorial-screen { max-width: 380px; margin: auto; padding-top: 12px; }
.tutorial-heading { position: relative; padding: 2px 2px 10px; }
.tutorial-progress { position: absolute; right: 2px; bottom: 14px; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.tutorial-dots { display: flex; gap: 5px; padding: 0 2px 12px; }
.tutorial-dots span { height: 3px; flex: 1; border-radius: 2px; background: #dce3da; }
.tutorial-dots .is-current { background: var(--forest); }
.lesson-card { padding: 14px; border: 1px solid #d9e1d8; border-radius: 16px; background: var(--surface); }
.lesson-heading { display: flex; align-items: center; gap: 9px; }
.lesson-heading > span { color: #87a18a; font-size: 13px; font-weight: 700; }
.lesson-heading h2 { margin: 0; font-size: 16px; line-height: 1.3; }
.lesson-description { min-height: 60px; margin: 12px 0 0; color: #345266; font-size: 14px; line-height: 1.55; }
.lesson-note { min-height: 50px; margin: 8px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.tutorial-demo { height: 180px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; margin-top: 12px; padding: 8px; overflow: hidden; border-radius: 12px; background: #f2f4ed; }
.tutorial-demo [data-at] { opacity: 0; transform: translateY(5px); transition: opacity .8s ease, transform .8s ease; }
.tutorial-demo [data-at="0"], .tutorial-demo .is-visible { opacity: 1; transform: translateY(0); }
.demo-caption { color: #5c7667; font-size: 11px; }
.demo-offers { display: flex; justify-content: center; gap: 20px; }
.demo-offer { position: relative; display: grid; justify-items: center; gap: 3px; color: #425f72; font-size: 12px; }
.demo-offer img { width: 48px; height: 48px; object-fit: contain; }
.demo-choice { position: absolute; top: -8px; padding: 3px 6px; border-radius: 6px; color: #fff; font-size: 10px; white-space: nowrap; }
.demo-choice--you { background: var(--blue); }
.demo-choice--other { background: var(--coral); }
.demo-result { min-height: 24px; display: grid; place-items: center; color: #315d49; font-size: 12px; font-weight: 700; text-align: center; }
.demo-result--coral { color: #ae5550; }
.demo-pair { display: flex; align-items: center; gap: 24px; }
.demo-pair > div { display: grid; justify-items: center; gap: 4px; color: #5b736d; font-size: 12px; }
.demo-versus { color: #96a299; }
.demo-flip { width: 56px; height: 56px; position: relative; }
.demo-flip img { width: 56px; height: 56px; object-fit: contain; }
.demo-flip > div { position: absolute; inset: 0; }
.demo-board { width: 112px; aspect-ratio: 1; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: repeat(3, minmax(0, 1fr)); gap: 3px; padding: 4px; border-radius: 9px; background: #e1e7dc; }
.demo-cell { min-width: 0; min-height: 0; overflow: hidden; display: grid; place-items: center; border-radius: 5px; background: #fffdf8; }
.demo-cell img { width: 100%; height: 100%; object-fit: contain; }
.demo-placement { position: relative; }
.demo-moving-tile { position: absolute; width: 32px; height: 32px; top: calc(50% - 16px); left: calc(50% - 16px); }
.demo-moving-tile img { width: 100%; height: 100%; }
.demo-score-examples { display: flex; gap: 18px; }
.demo-score-examples > div { display: grid; justify-items: center; gap: 8px; }
.demo-score-examples strong { color: var(--forest); font-size: 12px; }
.is-complete .demo-board--scored .demo-cell:nth-child(-n + 3) { outline: 1px solid #6fa383; background: #edf5e9; transition: background-color 1s ease; }
.demo-goal { color: #806f45; font-size: 11px; }
.demo-clock-labels { display: flex; width: 100%; justify-content: space-around; color: #657e72; font-size: 12px; }
.demo-clock-labels b { color: var(--forest); }
.demo-clock { width: 85%; height: 5px; border-radius: 3px; background: #dce5da; overflow: hidden; }
.demo-clock > div { height: 100%; background: var(--coral); transform-origin: left; }
.demo-auto-card { width: 54px; height: 54px; }
.demo-auto-card img { width: 100%; height: 100%; }
.demo-final-score { display: flex; align-items: center; justify-content: center; gap: 20px; color: #789085; }
.demo-final-score > div { display: grid; justify-items: center; gap: 6px; }
.demo-final-score strong { color: var(--forest); font-size: 34px; }
.demo-final-score small { font-size: 11px; }
.tutorial-playback { display: flex; justify-content: space-between; }
.tutorial-playback .text-button { font-size: 12px; }
.tutorial-navigation { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tutorial-screen .back-button { margin-top: 8px; }
@media (max-height: 650px) and (max-width: 600px) {
  .tutorial-demo { height: 154px; }
  .lesson-card { padding: 11px; }
  .lesson-description { min-height: 0; font-size: 13px; }
  .lesson-note { min-height: 0; }
}

.tutorial-demo .demo-moving-tile { transform: translate(-45px, 28px); transition: opacity 1s ease, transform 2s ease; }
.tutorial-demo .demo-moving-tile.is-visible { transform: translate(0, 0); }

.phase-panel.is-settled .phase-message { white-space: pre-line; font-size: 11px; line-height: 14px; }

.phase-message.is-credit-emphasis { color: #315b49; border-radius: 4px; background: #eef4e9; box-shadow: 0 0 0 4px #eef4e9; animation: round-credit-emphasis .26s ease-out both; }
@keyframes round-credit-emphasis { 0% { transform: scale(.98); } 35% { transform: scale(1.025); } 100% { transform: scale(1); } }
@keyframes burn-heat-front { 0%,18% { top: 98%; opacity: 0; } 22% { opacity: 1; } 35% { top: 76%; } 50% { top: 50%; } 65% { top: 24%; } 80%,100% { top: 0; opacity: 0; } }
