:root {
  color-scheme: dark;
  --bg: #101820;
  --panel: rgba(22, 35, 45, 0.92);
  --line: rgba(255, 255, 255, 0.14);
  --ink: #f7faf7;
  --muted: #aebbc3;
  --green: #63d84e;
  --yellow: #ffd44d;
}

html,
body,
*,
*::before,
*::after {
  box-sizing: border-box;
  cursor: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 12%, rgba(99, 216, 78, 0.22), transparent 28%),
    linear-gradient(180deg, #16232d 0%, var(--bg) 60%, #0c1218 100%);
  color: var(--ink);
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
}

button,
input {
  font: inherit;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 999px;
  padding: 0 18px;
  background: var(--green);
  color: #071208;
  font-weight: 900;
}

input {
  width: 100%;
  min-height: 42px;
  margin-top: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 12px;
  background: rgba(0, 0, 0, 0.22);
  color: var(--ink);
}

.shell {
  display: grid;
  gap: 14px;
  width: min(980px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.site-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 54px;
}

.mini-account,
.account-link,
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 12px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  text-decoration: none;
  font-weight: 900;
}

.account-link {
  background: var(--green);
  color: #071208;
}

.admin-link {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  border: 1px solid rgba(255, 212, 77, 0.24);
  border-radius: 999px;
  padding: 0 14px;
  background: rgba(255, 212, 77, 0.12);
  color: var(--yellow);
  text-decoration: none;
  font-weight: 900;
}

.mini-account {
  max-width: min(440px, 60vw);
}

.mini-account span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-profile-link {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.mini-profile-link:hover strong {
  color: var(--yellow);
}

.mini-account em {
  color: var(--muted);
  font-style: normal;
  font-weight: 650;
}

.mini-muted {
  color: var(--muted);
}

.avatar-badge {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 31px;
  height: 31px;
  border: 2px solid rgba(255, 255, 255, 0.88);
  border-radius: 50%;
  background: #05080c;
  color: var(--yellow);
  font-size: 0.9rem;
  font-weight: 950;
  line-height: 1;
}

.game-shell {
  display: grid;
  gap: 12px;
  width: min(1120px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 12px;
}

.game-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  padding: 14px;
}

.hero,
.panel {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.28);
}

.hero {
  min-height: 220px;
  display: grid;
  align-content: center;
  padding: 24px;
}

.hero.compact {
  min-height: 150px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.hero-actions .play-now-button,
.hero-actions button {
  min-width: 180px;
}

.alpha-note {
  display: grid;
  gap: 4px;
  border: 1px solid rgba(255, 212, 77, 0.3);
  border-radius: 14px;
  padding: 12px;
  background: rgba(255, 212, 77, 0.1);
}

.alpha-note strong {
  color: var(--yellow);
}

.alpha-note p {
  margin: 0;
  color: var(--muted);
  font-weight: 750;
  line-height: 1.35;
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  padding: 8px 0 18px;
}

.site-footer a {
  color: var(--muted);
  font-weight: 850;
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--yellow);
}

.legal-copy {
  display: grid;
  gap: 8px;
}

.legal-copy h2 {
  margin: 12px 0 0;
}

.legal-copy p {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
  line-height: 1.5;
}

.account-shell {
  min-height: 100vh;
  align-content: start;
}

.account-panel {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(320px, 1fr);
  gap: 18px;
  align-items: center;
  min-height: calc(100vh - 112px);
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  padding: 24px;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.28);
}

.account-card-large {
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.07);
}

.signed-in-panel {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  border: 1px solid rgba(99, 216, 78, 0.38);
  border-radius: 14px;
  padding: 12px;
  background: rgba(99, 216, 78, 0.11);
}

.signed-in-panel p {
  margin: 4px 0 0;
  color: var(--muted);
  font-weight: 750;
}

.username-setup-panel {
  display: grid;
  gap: 12px;
  border: 1px solid rgba(255, 211, 77, 0.48);
  border-radius: 16px;
  padding: 16px;
  background:
    linear-gradient(135deg, rgba(255, 211, 77, 0.2), rgba(64, 196, 255, 0.1)),
    rgba(255, 255, 255, 0.06);
}

.username-setup-panel p {
  margin: 4px 0 0;
  color: var(--muted);
  font-weight: 750;
}

.username-setup-panel label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
  text-transform: uppercase;
}

.username-setup-panel input {
  width: 100%;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  padding: 13px 14px;
  background: rgba(4, 8, 13, 0.72);
  color: var(--text);
  font: inherit;
  font-weight: 900;
}

.success-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 2px solid rgba(99, 216, 78, 0.72);
  border-radius: 50%;
  background: #071208;
  color: var(--green);
  font-size: 0.76rem;
  font-weight: 950;
}

.play-now-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border-radius: 999px;
  padding: 0 16px;
  background: var(--yellow);
  color: #161109;
  font-weight: 950;
  text-decoration: none;
}

.signed-in-actions {
  display: flex;
  grid-column: 1 / -1;
  flex-wrap: wrap;
  gap: 8px;
}

.signed-in-actions .play-now-button {
  flex: 1 1 140px;
}

.secondary-link-button {
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.1);
  color: var(--ink);
}

.google-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  background: #f7faf7;
  color: #101820;
}

.google-mark {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #ffffff;
  color: #4285f4;
  font-weight: 950;
}

.divider {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.divider::before,
.divider::after {
  height: 1px;
  background: var(--line);
  content: "";
}

.stacked {
  grid-template-columns: 1fr;
  margin: 0;
}

.account-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
}

.secondary-button {
  background: rgba(255, 255, 255, 0.12);
  color: var(--ink);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--green);
  font-size: 0.75rem;
  font-weight: 900;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 10px;
  font-size: clamp(2.4rem, 7vw, 5rem);
  line-height: 0.95;
}

h2 {
  margin-bottom: 14px;
}

.copy,
.note {
  color: var(--muted);
  font-weight: 650;
  line-height: 1.45;
}

.panel {
  padding: 18px;
}

.tutorial-panel {
  display: grid;
  gap: 16px;
  border: 1px solid rgba(255, 212, 77, 0.28);
  border-radius: 18px;
  padding: 18px;
  background:
    linear-gradient(135deg, rgba(255, 212, 77, 0.13), rgba(99, 216, 78, 0.08)),
    var(--panel);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.28);
}

.tutorial-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.tutorial-head h2 {
  margin: 0;
  font-size: clamp(1.55rem, 3.6vw, 2.35rem);
  line-height: 1.05;
}

.tutorial-steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.tutorial-steps article {
  display: grid;
  gap: 7px;
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.18);
}

.tutorial-steps strong {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--green);
  color: #071208;
  font-weight: 950;
}

.tutorial-steps span {
  color: var(--ink);
  font-size: 1rem;
  font-weight: 950;
}

.tutorial-steps p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.36;
}

.tutorial-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.ghost-button {
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: transparent;
  color: var(--ink);
}

.board-panel {
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #05080c;
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.34);
}

#game-canvas {
  display: block;
  width: min(100%, 900px, calc((100vh - 315px) * 900 / 675));
  height: auto;
  aspect-ratio: 900 / 675;
  touch-action: none;
}

.controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  padding: 12px;
}

.tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.control {
  display: grid;
  gap: 4px;
  min-width: 130px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.control input[type="range"] {
  width: 150px;
  accent-color: var(--green);
}

.tool-panel input[type="range"] {
  min-height: 18px;
  height: 18px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

.control input[type="color"] {
  width: 72px;
  min-height: 42px;
  padding: 4px;
}

.tool-button,
.primary-action {
  min-width: 108px;
}

.tool-button {
  background: rgba(255, 255, 255, 0.12);
  color: var(--ink);
}

.tool-button.is-active {
  background: var(--green);
  color: #071208;
}

.status-card {
  display: grid;
  gap: 4px;
  min-width: 120px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px;
  background: rgba(0, 0, 0, 0.18);
}

.status-card span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.status-card strong {
  color: var(--yellow);
  font-size: 1rem;
}

.result,
.match-card {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.match-card img {
  width: min(100%, 420px);
  border-radius: 12px;
}

.phase-pill,
.copy-link {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  min-height: 34px;
  border-radius: 999px;
  padding: 0 12px;
  background: rgba(255, 212, 77, 0.16);
  color: var(--yellow);
  font-weight: 900;
}

.copy-link {
  background: rgba(99, 216, 78, 0.16);
  color: var(--green);
}

.rank-list,
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.auth-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0;
}

.wide-button {
  width: auto;
  min-width: 112px;
  padding: 0 18px;
}

.rank-list span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 11px;
  color: var(--muted);
  font-weight: 850;
}

.mini-link {
  color: inherit;
  font-weight: 900;
  text-decoration: none;
}

.mini-link:hover {
  color: var(--yellow);
}

.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  min-height: 28px;
  border-radius: 999px;
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.12);
  color: var(--ink);
}

.rank-plastic { color: #d8e2e7; }
.rank-bronze { color: #d9985f; }
.rank-silver { color: #d9e2e8; }
.rank-gold { color: #ffd44d; }
.rank-platinum { color: #8de8d6; }
.rank-diamond { color: #7cc7ff; }
.rank-champion { color: #ff8fb4; }
.rank-grand-champion { color: #dba4ff; }
.rank-master { color: #ffffff; background: rgba(255, 212, 77, 0.22); }

.leaderboard {
  display: grid;
  gap: 8px;
}

.service-status,
.service-grid {
  display: grid;
  gap: 8px;
}

.service-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid rgba(99, 216, 78, 0.24);
  border-radius: 12px;
  padding: 10px 12px;
  background: rgba(99, 216, 78, 0.09);
}

.service-summary span {
  color: var(--muted);
  font-weight: 800;
}

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

.service-check {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.06);
}

.service-check span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.service-check strong {
  display: block;
  margin-top: 4px;
  color: var(--yellow);
}

.service-check.is-ready strong {
  color: var(--green);
}

.service-check p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 650;
  line-height: 1.3;
}

.admin-shell {
  width: min(1120px, 100%);
}

.admin-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.admin-metric,
.admin-row {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
}

.admin-metric {
  display: grid;
  gap: 4px;
  padding: 12px;
}

.admin-metric span,
.admin-row span {
  color: var(--muted);
  font-weight: 800;
}

.admin-metric span {
  font-size: 0.72rem;
  text-transform: uppercase;
}

.admin-metric strong {
  color: var(--green);
  font-size: 1.8rem;
  line-height: 1;
}

.admin-list {
  display: grid;
  gap: 8px;
}

.image-review-toolbar {
  display: grid;
  grid-template-columns: 180px minmax(220px, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin: 14px 0;
}

.image-upload-panel {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto minmax(260px, 1fr);
  gap: 10px;
  align-items: end;
  margin: 14px 0 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
}

.image-upload-panel label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.image-upload-panel input {
  width: 100%;
  color: var(--ink);
}

.image-upload-panel .note {
  align-self: center;
  margin: 0;
}

.image-review-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.cleanup-actions {
  display: grid;
  grid-template-columns: minmax(180px, 220px) auto minmax(220px, 1fr);
  gap: 10px;
  align-items: end;
}

.cleanup-actions label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.cleanup-actions select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 12px;
  background: rgba(0, 0, 0, 0.22);
  color: var(--ink);
}

.image-card {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.06);
}

.image-card.is-saving {
  opacity: 0.65;
}

.image-card.is-previewing {
  grid-column: 1 / -1;
  grid-template-columns: minmax(320px, 1.2fr) minmax(260px, 0.8fr);
}

.image-preview-button {
  overflow: hidden;
  width: 100%;
  min-height: 142px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 10px;
  padding: 0;
  background: #05080c;
}

.image-preview-button img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.image-card.is-previewing .image-preview-button img {
  max-height: 520px;
}

.image-card-body {
  display: grid;
  gap: 9px;
  min-width: 0;
}

.image-card-body strong {
  display: block;
  overflow: hidden;
  color: var(--ink);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-card-body span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.image-review-controls {
  display: grid;
  grid-template-columns: 82px 82px minmax(96px, 1fr);
  gap: 8px;
}

.image-review-controls label,
.image-review-toolbar label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.image-review-controls input,
.image-review-controls select,
.image-review-toolbar input,
.image-review-toolbar select,
.image-card textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 9px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--ink);
}

.image-card textarea {
  min-height: 54px;
  resize: vertical;
}

.image-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.image-actions button {
  min-height: 38px;
  padding: 8px 11px;
}

.profile-stats,
.result-board {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.profile-stats {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.profile-rank-card {
  display: grid;
  grid-column: span 2;
  gap: 12px;
  border: 1px solid rgba(255, 212, 77, 0.25);
  border-radius: 14px;
  padding: 14px;
  background: linear-gradient(135deg, rgba(255, 212, 77, 0.16), rgba(99, 216, 78, 0.08));
}

.profile-rank-card > div:first-child {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.profile-rank-card span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.rank-progress {
  display: grid;
  gap: 6px;
}

.rank-progress-bar {
  height: 12px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.22);
}

.rank-progress-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--yellow));
}

.rank-progress p {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
}

.result-player {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.07);
}

.result-player-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.result-player span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.result-player h2 {
  margin: 0;
}

.result-player strong {
  color: var(--green);
  font-size: 2.4rem;
  line-height: 1;
}

.result-note {
  display: grid;
  grid-column: 1 / -1;
  gap: 3px;
  border: 1px solid rgba(255, 212, 77, 0.24);
  border-radius: 12px;
  padding: 12px;
  background: rgba(255, 212, 77, 0.08);
}

.result-note strong {
  color: var(--yellow);
}

.result-note span {
  color: var(--muted);
  font-weight: 800;
}

.admin-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
}

.admin-row > div {
  display: grid;
  gap: 3px;
}

.admin-row > div:last-child {
  text-align: right;
}

.history-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid rgba(255, 212, 77, 0.18);
  border-radius: 14px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.06);
}

.history-card > div {
  display: grid;
  gap: 4px;
}

.history-card > div:last-child {
  justify-items: end;
  text-align: right;
}

.history-card span {
  color: var(--muted);
  font-weight: 850;
}

.rating-delta {
  color: var(--muted);
  font-weight: 900;
}

.rating-delta.positive {
  color: var(--green);
}

.rating-delta.negative {
  color: var(--red);
}

.match-history {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.active-match {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.resume-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid rgba(99, 216, 78, 0.32);
  border-radius: 14px;
  padding: 12px;
  background: rgba(99, 216, 78, 0.1);
}

.resume-card div {
  display: grid;
  gap: 3px;
}

.resume-card span {
  color: var(--muted);
  font-weight: 850;
}

.match-history h3 {
  margin: 8px 0 0;
  color: var(--yellow);
  font-size: 0.82rem;
  text-transform: uppercase;
}

.leader-row {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) repeat(3, auto);
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.06);
}

.history-row {
  display: grid;
  grid-template-columns: minmax(90px, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  border: 1px solid rgba(255, 212, 77, 0.18);
  border-radius: 12px;
  padding: 9px 10px;
  background: rgba(255, 212, 77, 0.08);
}

.leader-row span,
.history-row span {
  color: var(--muted);
  font-weight: 850;
}

.is-hidden {
  display: none !important;
}

@media (max-width: 760px) {
  .game-top,
  .controls,
  .leader-row,
  .history-row,
  .auth-grid,
  .account-panel,
  .account-actions,
  .service-grid,
  .admin-metrics,
  .admin-row,
  .cleanup-actions,
  .image-upload-panel,
  .image-review-toolbar,
  .image-review-grid,
  .image-card,
  .image-card.is-previewing,
  .profile-stats,
  .result-board,
  .profile-rank-card,
  .signed-in-panel,
  .tutorial-steps,
  .history-card,
  .resume-card {
    grid-template-columns: 1fr;
  }

  .profile-rank-card {
    grid-column: auto;
  }

  .site-topbar {
    align-items: stretch;
    flex-direction: column-reverse;
  }

  .mini-account,
  .account-link,
  .admin-link,
  .back-link {
    justify-content: center;
    width: 100%;
  }

  .mini-account {
    max-width: none;
  }

  .primary-action {
    width: 100%;
  }
}

.app-shell {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 12px;
  width: min(1180px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 12px;
}

.duel-hud,
.play-area {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(14px);
}

.duel-hud {
  display: grid;
  grid-template-columns: auto minmax(290px, 370px) minmax(250px, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
}

.stage-header h2 {
  margin: 0;
  letter-spacing: 0;
}

.duel-brand {
  padding: 0 10px;
  color: var(--ink);
  font-size: 1.55rem;
  font-weight: 900;
  line-height: 1;
  text-decoration: none;
}

.score-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.score-row article,
.match-meta div,
.score-row article,
.match-meta div {
  display: grid;
  align-content: center;
  min-height: 72px;
  padding: 10px;
}

.score-row span,
.match-meta span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.score-row strong {
  display: block;
  margin-top: 4px;
  color: var(--green);
  font-size: 1.8rem;
  font-weight: 900;
  line-height: 1;
}

.duel-player-line {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.duel-player-line > span {
  overflow: hidden;
  color: var(--ink);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.duel-rank-badge {
  flex: 0 0 auto;
  border: 1px solid currentColor;
  border-radius: 999px;
  padding: 2px 6px;
  color: var(--muted);
  font-size: 0.56rem;
  font-style: normal;
  font-weight: 950;
  line-height: 1.2;
  text-transform: uppercase;
}

.duel-rank-badge.rank-plastic { color: #c7d0d4; }
.duel-rank-badge.rank-bronze { color: #d28a5b; }
.duel-rank-badge.rank-silver { color: #d7e2e8; }
.duel-rank-badge.rank-gold { color: #ffd44d; }
.duel-rank-badge.rank-platinum { color: #6fe0ce; }
.duel-rank-badge.rank-diamond { color: #68b9ff; }
.duel-rank-badge.rank-champion { color: #ff75a8; }
.duel-rank-badge.rank-grand-champion { color: #ff7a68; }
.duel-rank-badge.rank-master { color: #d99cff; }

.sound-toggle {
  display: grid;
  place-items: center;
  width: 42px;
  min-width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
}

.sound-toggle svg {
  width: 23px;
  height: 23px;
  fill: currentColor;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.sound-toggle .sound-off-icon,
.sound-toggle.is-muted .sound-on-icon {
  display: none;
}

.sound-toggle.is-muted .sound-off-icon {
  display: block;
}

.match-meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.match-meta strong {
  margin-top: 4px;
  font-size: 1rem;
  font-weight: 850;
}

.connection-state {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 116px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 13px;
  color: var(--muted);
  font-size: 0.78rem;
}

.connection-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--yellow);
  box-shadow: 0 0 9px currentColor;
}

.connection-state[data-state="connected"] {
  color: var(--green);
}

.connection-state[data-state="offline"],
.connection-state[data-state="replaced"] {
  color: #ff7373;
}

.connection-state[data-state="reconnecting"] .connection-dot,
.connection-state[data-state="connecting"] .connection-dot {
  animation: connection-pulse 0.8s ease-in-out infinite alternate;
}

@keyframes connection-pulse {
  to {
    opacity: 0.3;
  }
}

.play-area {
  display: grid;
  grid-template-rows: auto auto auto auto;
  justify-items: center;
  gap: 10px;
  min-width: 0;
  padding: 12px;
}

.stage-header,
.canvas-wrap,
.match-summary,
.tool-panel,
.join-panel {
  width: min(100%, 900px);
}

.stage-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.stage-header h2 {
  font-size: clamp(1.45rem, 2.6vw, 2.25rem);
  font-weight: 900;
  line-height: 1.05;
}

.phase-instruction {
  max-width: 720px;
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.98rem;
  font-weight: 650;
  line-height: 1.35;
}

.stage-timer {
  display: grid;
  place-items: center;
  min-width: 112px;
  min-height: 72px;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.28);
}

.stage-timer span {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 850;
  text-transform: uppercase;
}

.stage-timer strong {
  color: var(--yellow);
  font-size: 2rem;
  font-weight: 900;
  line-height: 1;
}

body.timer-warning .play-area {
  animation: danger-pulse 0.72s ease-in-out infinite alternate;
}

@keyframes danger-pulse {
  from {
    box-shadow: 0 18px 44px rgba(0, 0, 0, 0.34);
  }
  to {
    box-shadow: 0 0 0 3px rgba(255, 78, 78, 0.52), 0 18px 54px rgba(255, 78, 78, 0.24);
  }
}

.canvas-wrap {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 18px;
  background: #05080c;
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.36);
}

.game-notice {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 9px;
  padding: 24px;
  background: rgba(5, 8, 12, 0.7);
  text-align: center;
  backdrop-filter: blur(5px);
}

.game-notice strong {
  font-size: clamp(1.2rem, 3vw, 2rem);
}

.game-notice span {
  max-width: 520px;
  color: var(--muted);
  font-weight: 700;
}

.game-notice.is-terminal {
  background: rgba(5, 8, 12, 0.82);
}

.notice-spinner {
  width: 32px;
  height: 32px;
  border: 4px solid rgba(255, 255, 255, 0.18);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: notice-spin 0.8s linear infinite;
}

@keyframes notice-spin {
  to {
    transform: rotate(360deg);
  }
}

.online-duel-shell #game-canvas {
  display: block;
  width: min(100%, 900px, calc((100vh - 285px) * 900 / 675));
  height: auto;
  aspect-ratio: 900 / 675;
  touch-action: none;
}

body.has-active-tools .online-duel-shell #game-canvas {
  width: min(100%, 900px, calc((100vh - 430px) * 900 / 675));
}

.game-cursor {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 9999;
  display: none;
  width: 18px;
  height: 20px;
  pointer-events: none;
  transform: translate(-100px, -100px);
  filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.38));
}

.game-cursor.is-visible {
  display: block;
}

.game-cursor::before {
  display: none;
}

.game-cursor svg {
  display: block;
  width: 18px;
  height: 20px;
}

.game-cursor path {
  fill: #05080c;
  stroke: #f7faf7;
  stroke-width: 1.4;
  stroke-linejoin: round;
  transition: fill 90ms ease, stroke 90ms ease;
}

.game-cursor.is-clickable {
  filter: drop-shadow(0 0 8px rgba(255, 212, 77, 0.7)) drop-shadow(0 3px 5px rgba(0, 0, 0, 0.38));
}

.game-cursor.is-clickable path {
  fill: #ffd44d;
  stroke: #05080c;
}

.tool-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.tool-panel .actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tool-buttons {
  display: flex;
  gap: 7px;
}

.tool-button {
  display: grid;
  place-items: center;
  width: 42px;
  min-width: 42px;
  height: 42px;
  padding: 0;
}

.zoom-control {
  min-width: 132px;
}

.zoom-buttons,
.reveal-tools {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
  padding: 4px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.22);
}

.reveal-tools {
  display: flex;
  gap: 6px;
}

.zoom-button,
.compare-button {
  min-height: 34px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.zoom-button.is-active {
  background: var(--green);
  color: #071208;
}

.compare-button.is-active {
  background: var(--yellow);
  color: #161109;
}

.color-control {
  min-width: 210px;
}

.rgb-picker {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 3px 8px;
  align-items: center;
}

.color-preview {
  grid-row: span 3;
  width: 32px;
  height: 48px;
  border: 2px solid rgba(255, 255, 255, 0.28);
  border-radius: 10px;
  background: #15171d;
}

.rgb-picker label {
  display: grid;
  grid-template-columns: 14px 1fr;
  align-items: center;
  gap: 5px;
}

.rgb-picker b {
  color: var(--muted);
  font-size: 0.7rem;
}

.rgb-picker input {
  width: 100%;
  min-height: 18px;
  accent-color: var(--green);
}

.blend-score {
  min-height: 34px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 212, 77, 0.18);
  color: var(--yellow);
  font-size: 0.9rem;
  font-weight: 900;
  white-space: nowrap;
}

.match-summary {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(255, 212, 77, 0.34);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255, 212, 77, 0.16), rgba(255, 255, 255, 0.07));
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.22);
}

.summary-head,
.summary-score {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.summary-head h3 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 950;
}

.summary-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.winner-pill {
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--yellow);
  color: #161109;
  font-size: 0.85rem;
  font-weight: 950;
}

.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.summary-player {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.18);
}

.summary-player.is-winner {
  border-color: rgba(99, 216, 78, 0.65);
}

.summary-score span,
.summary-stats span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.summary-score strong {
  color: var(--green);
  font-size: 2rem;
  font-weight: 950;
  line-height: 1;
}

.summary-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.summary-stats div {
  min-width: 0;
  padding: 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.07);
}

.summary-stats strong {
  display: block;
  margin-top: 3px;
  font-size: 1rem;
  font-weight: 950;
}

.brush-icon,
.eraser-icon,
.eyedropper-icon {
  position: relative;
  display: block;
}

.tool-svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 3;
}

.brush-icon {
  width: 28px;
  height: 28px;
  transform: rotate(-42deg);
}

.brush-icon::before {
  position: absolute;
  left: 11px;
  top: 1px;
  width: 6px;
  height: 17px;
  border-radius: 6px 6px 3px 3px;
  background: linear-gradient(#7b573c 0 68%, #c8b08d 68% 82%, #5d6870 82% 100%);
  content: "";
}

.brush-icon::after {
  position: absolute;
  left: 7px;
  top: 17px;
  width: 14px;
  height: 10px;
  border-radius: 4px 4px 11px 11px;
  background: #ff5a78;
  clip-path: polygon(14% 0, 86% 0, 100% 50%, 50% 100%, 0 50%);
  content: "";
}

.eraser-icon {
  width: 27px;
  height: 17px;
  transform: rotate(-28deg);
}

.eraser-icon::before {
  position: absolute;
  inset: 0;
  border-radius: 4px;
  background: linear-gradient(90deg, #ff8fa1 0 58%, #f3f8fa 58% 100%);
  content: "";
}

.eraser-icon::after {
  position: absolute;
  left: 13px;
  top: 1px;
  width: 1px;
  height: 14px;
  background: rgba(0, 0, 0, 0.25);
  content: "";
}

.eyedropper-icon {
  width: 27px;
  height: 27px;
  transform: rotate(-43deg);
}

.eyedropper-icon::before {
  position: absolute;
  left: 10px;
  top: 2px;
  width: 7px;
  height: 19px;
  border-radius: 5px;
  background: #8dd7f0;
  box-shadow: 0 -3px 0 2px #253442, 0 15px 0 -1px #f2f6f4;
  content: "";
}

.eyedropper-icon::after {
  position: absolute;
  left: 8px;
  top: 19px;
  width: 11px;
  height: 5px;
  border-radius: 0 0 8px 8px;
  background: var(--blue);
  content: "";
}

@media (max-width: 960px) {
  .duel-hud {
    grid-template-columns: auto minmax(260px, 1fr) auto auto;
  }

  .duel-hud .match-meta {
    grid-column: 1 / -1;
  }

  .match-meta,
  .summary-grid,
  .summary-stats,
  .tool-panel {
    grid-template-columns: 1fr;
  }

  .summary-head {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 560px) {
  .app-shell {
    padding: 8px;
  }

  .duel-hud,
  .play-area {
    padding: 10px;
  }

  .duel-hud {
    grid-template-columns: 1fr auto;
  }

  .duel-hud .score-row,
  .duel-hud .match-meta {
    grid-column: 1 / -1;
  }

  .duel-hud .connection-state {
    grid-column: 1;
  }

  .duel-hud .sound-toggle {
    grid-column: 2;
  }

  .duel-hud .match-meta {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .duel-hud .match-meta div {
    min-height: 58px;
    padding: 8px;
  }

  .duel-hud .match-meta strong {
    overflow: hidden;
    font-size: 0.82rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .stage-header {
    grid-template-columns: 1fr;
  }

  .stage-timer,
  .primary-button {
    width: 100%;
  }
}
