/* Playfield toolbar, result receipt, and ranking layout. */

body.playing {
  background: #201710;
}

body.playing .game-shell {
  position: relative;
  width: min(100vw, 480px);
  height: 100dvh;
  max-height: none;
  padding: max(6px, env(safe-area-inset-top)) 8px max(6px, env(safe-area-inset-bottom));
  gap: 6px;
  grid-template-rows: 46px 40px minmax(0, 1fr);
}

.hud {
  gap: 6px;
  padding: 0;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.hud-card {
  padding: 4px;
  border: 1px solid #a78250;
  border-radius: 10px;
  background: linear-gradient(#efdbb8, #d7b985);
  box-shadow: inset 0 1px 0 #fff5;
}

.hud .label {
  font-size: 10px;
  line-height: 1.15;
  color: #725333;
}

.hud .value {
  font-size: 20px;
  line-height: 1.15;
  color: #493325;
}

.star-strip {
  position: static;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  z-index: auto;
}

.phase-badge {
  padding: 5px 10px;
  font-size: 11px;
  border: 1px solid #8d704a;
  background: #352a20;
  color: #e9cea2;
  box-shadow: none;
}

.top-actions {
  gap: 6px;
}

.round-action {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 10px;
  background: linear-gradient(#50402e, #34281e);
  border: 1px solid #a78250;
  box-shadow: inset 0 1px 0 #ffffff20;
  cursor: pointer;
  touch-action: manipulation;
}

.round-action svg {
  width: 22px;
  height: 22px;
  stroke: #f0d3a1;
  fill: none;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.round-action:hover {
  filter: brightness(1.15);
}

.round-action:active {
  transform: translateY(1px);
}

.round-action:focus-visible {
  outline: 2px solid #ffdea1;
  outline-offset: 2px;
}

.round-action[aria-pressed="true"] {
  background: #252b36;
  opacity: 0.85;
}

.battlefield {
  grid-row: 3;
  border: 1px solid #9e784a;
  border-radius: 16px;
  box-shadow: 0 4px 16px #0004;
  min-height: 0;
}

.controls {
  display: none;
}

#gameCanvas {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

body.counting-down .top-actions,
body.counting-down .round-action,
body.counting-down .battlefield {
  pointer-events: none;
}

body.counting-down .round-action {
  opacity: 0.4;
  cursor: default;
}

.landing-content button,
dialog button {
  font-family: inherit;
}

dialog {
  font-family: inherit;
}

dialog button {
  min-height: 44px;
  cursor: pointer;
}

.result-card {
  border-width: 1px;
  border-radius: 16px;
}

/* Ranking rows inside dialogs and the result receipt. */

.online-ranking {
  max-height: 55dvh;
  overflow: auto;
  padding: 6px 0;
}

.online-ranking > a {
  display: block;
  color: #674325;
  padding: 16px 0;
}

.online-result {
  max-height: 30vh;
  overflow-y: auto;
  margin: 12px 0;
  font-size: 13px;
}

.online-result h3 {
  margin: 12px 0 8px;
}

.online-rank-row {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) minmax(52px, auto);
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid #b38a5055;
  padding: 10px 0;
  text-align: left;
}

.online-rank-header {
  font-size: 11px;
  color: #725333;
  border-bottom: 1px solid #b38a5088;
  padding: 8px 0;
}

.online-rank-header > strong:nth-child(2) {
  padding-left: 40px;
}

.online-rank-row > strong:first-child {
  text-align: center;
}

.online-rank-row > strong:last-child {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.online-rank-row a,
.online-result .online-rank-row a {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 8px;
  row-gap: 3px;
  min-width: 0;
  color: #4d3424;
  text-decoration: none;
}

.online-rank-row a img,
.online-rank-row img {
  grid-column: 1;
  grid-row: 1 / 3;
  width: 32px;
  height: 32px;
  align-self: center;
  border-radius: 50%;
  object-fit: cover;
}

.online-rank-row a span {
  grid-column: 2;
  grid-row: 1;
  overflow-wrap: anywhere;
}

.online-rank-row a small,
.online-rank-row small {
  grid-column: 2;
  grid-row: 2;
  font-size: 10px;
  color: #725333;
}

.online-result a,
.online-status-dialog a {
  color: #78522b;
}

.online-status-dialog {
  max-width: min(340px, 88vw);
  border: 1px solid #b58b50;
  border-radius: 18px;
  padding: 24px;
  background: #f7e7c8;
  color: #4f3421;
  text-align: center;
}

.online-status-dialog button {
  display: block;
  margin: 14px auto;
}

.online-status-dialog::backdrop {
  background: #160f0bbb;
}

#endOverlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right))
    max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  overflow-y: auto;
  overscroll-behavior: contain;
  background: #160f0bbf;
}

#endOverlay .result-card {
  width: min(100%, 420px);
  min-width: 0;
  max-height: 100%;
  margin: auto;
  padding: clamp(16px, 4vw, 26px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

#endOverlay .result-badge {
  position: static;
  margin: 0 auto 10px;
  transform: none;
}

#endOverlay .result-grid {
  gap: 8px;
}

#endOverlay .result-stat {
  min-width: 0;
  padding: 10px 4px;
}

#endOverlay .result-stat strong {
  font-size: clamp(18px, 5vw, 28px);
  overflow-wrap: anywhere;
}

#endOverlay .online-result {
  max-height: none;
  overflow: visible;
  overflow-wrap: anywhere;
}

#endOverlay #playAgainBtn {
  min-height: 44px;
}

@media (max-height: 480px) {
  #endOverlay .result-badge {
    width: 40px;
    height: 40px;
    margin-bottom: 4px;
  }

  #endOverlay .result-card h2 {
    margin: 6px 0 12px;
    font-size: 22px;
  }
}
.rank-medal { --medal-light:#fff3ac; --medal-main:#e4b144; --medal-dark:#96601a; position:relative; isolation:isolate; display:grid; place-items:center; width:34px; height:42px; justify-self:center; }
.rank-medal-2 { --medal-light:#f5f7fa; --medal-main:#b9c2cd; --medal-dark:#657487; }
.rank-medal-3 { --medal-light:#f9d5b2; --medal-main:#c68b59; --medal-dark:#82472b; }
.rank-medal::before { content:''; position:absolute; top:0; width:23px; height:19px; background:linear-gradient(90deg,#7e3f2d 0 34%,#f0d2a0 34% 43%,#9d5539 43% 57%,#f0d2a0 57% 66%,#7e3f2d 66%); clip-path:polygon(0 0,100% 0,85% 100%,50% 80%,15% 100%); z-index:-1; }
.rank-medal span { display:grid; place-items:center; width:30px; height:30px; margin-top:10px; border-radius:50%; border:1px solid var(--medal-dark); background:linear-gradient(135deg,var(--medal-light),var(--medal-main) 55%,var(--medal-dark)); color:var(--medal-dark); box-shadow:inset 0 0 0 2px var(--medal-main),inset 0 0 0 3px var(--medal-light),0 2px 3px #4f342133; font-size:15px; font-weight:900; text-shadow:0 1px 0 var(--medal-light); }
