/* ===== CSS Custom Properties (Themes) ===== */
:root {
  --bg: #f0f2f5;
  --surface: #ffffff;
  --surface-hover: #f8f9fa;
  --text: #1a1a2e;
  --text-muted: #6c757d;
  --accent: #4a6cf7;
  --accent-hover: #3b5de7;
  --accent-light: rgba(74, 108, 247, 0.1);
  --danger: #e74c3c;
  --success: #27ae60;
  --border: #e0e0e0;
  --die-bg: #ffffff;
  --die-border: #d0d0d0;
  --pip-color: #1a1a2e;
  --held-glow: #4a6cf7;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 4px 20px rgba(0, 0, 0, 0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --transition: 0.2s ease;
  --score-mine: #4a6cf7;
  --score-opponent: #e74c3c;
  --score-preview: rgba(74, 108, 247, 0.4);
}

[data-theme="dark"] {
  --bg: #0f0f1a;
  --surface: #1a1a2e;
  --surface-hover: #222240;
  --text: #e8e8f0;
  --text-muted: #9999b0;
  --accent: #6c8cff;
  --accent-hover: #5a7af0;
  --accent-light: rgba(108, 140, 255, 0.12);
  --danger: #ff6b6b;
  --success: #51cf66;
  --border: #2a2a40;
  --die-bg: #222240;
  --die-border: #3a3a5a;
  --pip-color: #e8e8f0;
  --held-glow: #6c8cff;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 4px 20px rgba(0, 0, 0, 0.4);
  --score-mine: #6c8cff;
  --score-opponent: #ff6b6b;
  --score-preview: rgba(108, 140, 255, 0.55);
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
  -webkit-font-smoothing: antialiased;
}

/* ===== Header ===== */
header {
  display: flex;
  flex-direction: column;
  padding: 16px 24px 0;
  max-width: 640px;
  margin: 0 auto 12px;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.header-top-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}

header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0;
}

.app-version {
  font-size: 0.65rem;
  color: var(--text-muted);
  opacity: 0.5;
  margin-left: 4px;
  font-weight: 400;
  position: relative;
  top: 1px;
}

.header-controls {
  display: none;
  gap: 6px;
  padding-top: 8px;
  margin-bottom: 4px;
  width: 100%;
}

body.in-game .header-controls {
  display: flex;
}

body.in-game header {
  margin-bottom: 0;
}

body.in-game .screen {
  padding-top: 0;
}

.header-controls .btn-icon {
  flex: 1;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 5px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-muted);
  text-align: center;
  transition: background var(--transition), color var(--transition);
}

.header-controls .btn-icon:hover {
  background: var(--accent);
  color: #fff;
}

.fast-mode-toggle {
  display: none;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  user-select: none;
}

body.in-game.is-bot-game .fast-mode-toggle {
  display: flex;
}

.fast-mode-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.toggle-switch {
  position: relative;
  width: 32px;
  height: 18px;
  background: var(--border);
  border-radius: 9px;
  transition: background 0.2s;
}

.toggle-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}

.fast-mode-toggle.active .toggle-switch {
  background: var(--accent);
}

.fast-mode-toggle.active .toggle-knob {
  transform: translateX(14px);
}

.fast-mode-toggle.active .fast-mode-label {
  color: var(--accent);
}

body.fast-mode .die.rolling {
  animation-duration: 0.13s;
}

.header-controls .btn-leave {
  color: var(--danger) !important;
  border-color: var(--danger);
}

.header-controls .btn-leave:hover {
  background: var(--danger);
  color: #fff !important;
}

.header-top-controls #lang-toggle,
#theme-toggle,
#bgm-toggle {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  padding: 0;
  transition: background var(--transition), border-color var(--transition), opacity var(--transition);
  color: var(--text);
}

.header-top-controls #lang-toggle {
  font-size: 0.75rem;
  font-weight: 600;
}

.header-top-controls #lang-toggle:hover,
#theme-toggle:hover,
#bgm-toggle:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: inline; }

/* ===== Screens ===== */
.screen {
  display: none;
  max-width: 640px;
  margin: 0 auto;
  padding: 12px 24px 24px;
  animation: fadeSlideIn 0.3s ease;
}

.screen.active {
  display: block;
}

.screen.no-anim {
  animation: none;
}

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Card ===== */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow);
  transition: background var(--transition);
}

.card-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.card-header-row h2 {
  font-size: 1.4rem;
  margin-bottom: 0;
}

.card > p.screen-nickname {
  font-weight: 400;
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0;
}

.screen-nickname:empty {
  display: none;
}

.stats-header-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 12px;
}

.stats-header-row h2 {
  margin-bottom: 0;
}

.stats-nickname-inline {
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--text-muted);
}

.stats-nickname-inline:empty {
  display: none;
}

.card-header-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.card-header-row .btn-tutorial {
  margin: 0;
  position: relative;
  top: -2px;
}

.card h2 {
  font-size: 1.4rem;
  margin-bottom: 8px;
}

.card > p {
  color: var(--text-muted);
  margin-top: 0;
  margin-bottom: 20px;
  font-size: 0.95rem;
  white-space: pre-line;
}

.welcome-tagline {
  font-size: 0.95rem !important;
  margin-bottom: 12px !important;
  color: var(--text-muted);
}

[data-i18n] {
  white-space: pre-line;
}

/* ===== Inputs ===== */
input[type="text"] {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  outline: none;
  transition: border-color var(--transition), background var(--transition);
}

input[type="text"]:focus {
  border-color: var(--accent);
}

input[type="text"]::placeholder {
  color: var(--text-muted);
}

/* ===== Buttons ===== */
.btn-primary {
  width: 100%;
  padding: 12px 24px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), opacity var(--transition);
  min-height: 44px;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-danger {
  background: var(--danger);
}

.btn-danger:hover {
  opacity: 0.9;
}

.btn-secondary {
  padding: 12px 24px;
  background: var(--surface);
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
  min-height: 44px;
}

.btn-secondary:hover:not(:disabled) {
  background: var(--accent-light);
}

.btn-secondary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.2rem;
  padding: 4px 8px;
  color: var(--text-muted);
  transition: color var(--transition);
}

.btn-icon:hover {
  color: var(--accent);
}

#bgm-toggle {
  position: relative;
}

#bgm-toggle.bgm-off::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 22px;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
  transform: translate(-50%, -50%) rotate(-45deg);
  pointer-events: none;
}

/* ===== Google Sign-In ===== */
.btn-google {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 8px;
  padding: 12px 24px;
  background: #fff;
  color: #444;
  border: 1px solid #ddd;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
  transition: background 0.2s, box-shadow 0.2s;
}

.btn-google:hover {
  background: #f7f7f7;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

[data-theme="dark"] .btn-google {
  background: #2a2a4a;
  color: var(--text);
  border-color: var(--border);
}

[data-theme="dark"] .btn-google:hover {
  background: #333358;
}

.google-disclaimer {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 12px !important;
  opacity: 0.7;
  white-space: pre-line;
}

.lobby-bottom-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.lobby-bottom-row .btn-secondary {
  flex: 1;
}

.btn-feedback {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  margin-top: 16px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
  white-space: nowrap;
}

.btn-feedback:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.google-icon {
  flex-shrink: 0;
}

.guest-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
}

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

.btn-text {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 4px 0;
  text-decoration: underline;
}

.btn-text:hover {
  color: var(--accent-hover);
}

/* Signed-in profile */
.signed-in-profile {
  display: none;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: var(--accent-light);
  border-radius: var(--radius-sm);
  margin-top: 16px;
}

.signed-in-profile.visible {
  display: flex;
}

.user-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--accent);
  background: var(--accent-light) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Crect width='100' height='100' rx='50' fill='%23a0b4f0'/%3E%3Ccircle cx='32' cy='42' r='6' fill='%23fff'/%3E%3Ccircle cx='68' cy='42' r='6' fill='%23fff'/%3E%3Ccircle cx='32' cy='42' r='3' fill='%23222'/%3E%3Ccircle cx='68' cy='42' r='3' fill='%23222'/%3E%3Cpath d='M35 62 Q50 74 65 62' stroke='%23fff' stroke-width='3' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") center/cover no-repeat;
}

.user-info {
  flex: 1;
  min-width: 0;
}

.user-display-name {
  display: block;
  font-weight: 600;
  font-size: 1rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.signed-in-profile .btn-primary {
  width: 100%;
  margin-top: 4px;
}

/* ===== Stats Button ===== */
.btn-stats {
  display: block;
  margin: 12px auto 0;
  font-size: 0.9rem;
  text-decoration: none;
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-weight: 500;
}

.btn-stats:hover {
  text-decoration: underline;
}

/* ===== Stats & History ===== */
.stats-summary {
  margin-bottom: 20px;
}

.stat-winrate-streak-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stat-winrate-streak-col .stat-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.stat-winrate .stat-value {
  font-size: 1.4rem;
}

.stat-streak .stat-value {
  font-size: 1.4rem;
  color: var(--warning, #f0ad4e);
}

.result-criteria-box {
  padding: 10px 12px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  font-size: 0.68rem;
  line-height: 1.5;
  color: var(--text-muted);
}

.result-criteria-title {
  font-weight: 700;
  font-size: 0.72rem;
  margin-bottom: 2px;
  color: var(--text);
}

.result-criteria-item {
  word-break: break-word;
}

.result-criteria-note {
  margin-top: 2px;
  opacity: 0.7;
  font-size: 0.65rem;
}

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

.stat-card {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 12px 8px;
  text-align: center;
}

.stat-value {
  font-size: 1.4rem;
  font-weight: 700;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.stat-win .stat-value {
  color: var(--success);
}

.stat-loss .stat-value {
  color: var(--danger);
}

.history-title {
  font-size: 1rem;
  margin-bottom: 12px;
  color: var(--text);
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.history-table th,
.history-table td {
  padding: 8px 6px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}

.history-table th {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
}

.result-win { color: var(--success); font-weight: 700; }
.result-loss { color: var(--danger); font-weight: 700; }
.result-tie { color: var(--text-muted); font-weight: 600; }
.result-invalid { color: #999; }

.history-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 12px;
}

.btn-pager {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  font-size: 1rem;
  cursor: pointer;
  color: var(--text);
  transition: background var(--transition);
}

.btn-pager:hover:not(:disabled) {
  background: var(--accent);
  color: #fff;
}

.btn-pager:disabled {
  opacity: 0.3;
  cursor: default;
}

.pager-info {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
}

.no-history {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 24px 0;
}

/* ===== Lobby ===== */
.lobby-actions {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.join-section {
  display: flex;
  gap: 8px;
}

.join-section input {
  flex: 1;
  padding-top: 6px;
  padding-bottom: 6px;
}

.join-section .btn-secondary {
  flex-shrink: 0;
  width: auto;
  padding-top: 6px;
  padding-bottom: 6px;
}

.lobby-btn-row {
  display: flex;
  gap: 8px;
}

.lobby-btn-row .btn-primary {
  flex: 1;
  padding: 12px 8px;
  font-size: 0.85rem;
}

@media (max-width: 360px) {
  .lobby-btn-row {
    flex-direction: column;
  }
}

/* ===== Bot Section ===== */
.bot-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bot-mode-select .mode-options {
  display: flex;
  gap: 8px;
}

.bot-mode-select .mode-option {
  padding: 10px 8px;
}

.bot-difficulty {
  display: flex;
  gap: 8px;
}

.bot-option {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 8px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  text-align: center;
}

.bot-option:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-light);
}

.bot-option input {
  display: none;
}

.bot-label {
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 2px;
}

.bot-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.error-text {
  color: var(--danger);
  font-size: 0.85rem;
  margin-top: 12px;
}

/* ===== Waiting Room ===== */
.room-code-display {
  margin-bottom: 24px;
}

.room-code-display > p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 8px;
}

.code-box {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px;
  background: var(--accent-light);
  border-radius: var(--radius-sm);
}

.code-box span {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.3em;
  color: var(--accent);
  font-family: 'Courier New', monospace;
}

.mode-select {
  margin-bottom: 24px;
}

.mode-select > p {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.mode-options {
  display: flex;
  gap: 12px;
}

.mode-option {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  text-align: center;
}

.mode-option:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-light);
}

.mode-option input {
  display: none;
}

.mode-label {
  font-weight: 600;
  font-size: 1.1rem;
  margin-bottom: 4px;
}

.mode-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.waiting-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.waiting-spinner p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ===== Waiting Type Visibility ===== */
[data-wait-type="random"] .wait-private-only { display: none; }
[data-wait-type="private"] .wait-random-only { display: none; }

.waiting-tip {
  margin-top: 0;
  padding: 10px 14px;
  background: var(--accent-light);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.8rem;
  line-height: 1.45;
  text-align: center;
}

/* ===== Spinner ===== */
.spinner {
  width: 32px;
  height: 32px;
  font-size: 2rem;
  line-height: 32px;
  text-align: center;
  animation: diceSpin 1s linear infinite;
}

.spinner::after {
  content: '\2684';
  animation: diceFace 1.5s steps(1) infinite;
}

@keyframes diceSpin {
  to { transform: rotate(360deg); }
}

@keyframes diceFace {
  0%   { content: '\2680'; }
  16%  { content: '\2681'; }
  33%  { content: '\2682'; }
  50%  { content: '\2683'; }
  66%  { content: '\2684'; }
  83%  { content: '\2685'; }
}

.btn-dice-spinner {
  display: inline-block;
  animation: diceSpin 1s linear infinite;
}

.btn-dice-spinner::after {
  content: '\2684';
  animation: diceFace 1.5s steps(1) infinite;
}

/* ===== Game Layout ===== */
.game-layout {
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 80px);
}

.bottom-controls {
  padding-top: 12px;
}

/* ===== Dice + Roll Row ===== */
.dice-roll-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  width: 100%;
}

.dice-area {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
  flex-shrink: 0;
}

.die {
  width: clamp(52px, 13vw, 72px);
  height: clamp(52px, 13vw, 72px);
  background: var(--die-bg);
  border: 2px solid var(--die-border);
  border-radius: var(--radius-sm);
  display: grid;
  grid-template-rows: repeat(3, 1fr);
  grid-template-columns: repeat(3, 1fr);
  padding: 8px;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
  user-select: none;
  position: relative;
}

/* Held check badge */
.die .held-check {
  display: none;
}

.die.held .held-check {
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  top: -5px;
  left: -5px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  z-index: 2;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
  pointer-events: none;
}

.die.disabled {
  cursor: default;
}

.die.rolling {
  animation: diceShake 0.4s ease;
  opacity: 0.5;
}

@keyframes diceShake {
  0%, 100% { transform: translateX(0) rotate(0); }
  15% { transform: translateX(-4px) rotate(-5deg); }
  30% { transform: translateX(4px) rotate(5deg); }
  45% { transform: translateX(-3px) rotate(-3deg); }
  60% { transform: translateX(3px) rotate(3deg); }
  75% { transform: translateX(-2px) rotate(-1deg); }
  90% { transform: translateX(1px) rotate(1deg); }
}

.pip {
  width: clamp(8px, 2vw, 12px);
  height: clamp(8px, 2vw, 12px);
  border-radius: 50%;
  background: var(--pip-color);
  align-self: center;
  justify-self: center;
  transition: background var(--transition);
}

.pip.hidden {
  visibility: hidden;
}

.btn-roll {
  flex: 1;
  height: clamp(52px, 13vw, 72px);
  padding: 0 10px;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: normal;
  line-height: 1.2;
  border-radius: var(--radius-sm);
}

.btn-roll small {
  font-size: 0.75rem;
  font-weight: 500;
  opacity: 0.8;
}

.btn-roll:disabled {
  background: var(--border);
  color: var(--text-muted);
  cursor: default;
  opacity: 1;
}

/* ===== Dice Skins ===== */
/*
 * All skin colors are defined here in CSS only — JS sets data-dice-skin attribute,
 * CSS handles the rest. This ensures light↔dark theme toggle works in real time.
 *
 * Per-skin CSS pattern (see CLAUDE.md for full checklist):
 *   [data-dice-skin="<id>"] .die          — light mode body
 *   [data-dice-skin="<id>"] .pip          — light mode pips
 *   [data-theme="dark"] variants of above — dark mode overrides
 *
 * Held state: uses a universal .held-check badge — no per-skin held rules needed.
 *   .skin-preview-die[data-dice-skin="<id>"] — lobby preview (light + dark)
 *   .skin-option.active[data-skin-id="<id>"] — selection border (light + dark)
 */

/* --- Ornate: silver metal + copper border + emerald pips --- */
/* Light mode */
[data-dice-skin="ornate"] .die {
  border-width: 3px;
  border-style: solid;
  border-image: linear-gradient(145deg, #b87333, #d4a76a, #b87333) 1;
  background: linear-gradient(145deg, #e8e8ec, #c8c8d0, #d8d8e0);
  box-shadow: inset 0 1px 3px rgba(255,255,255,0.5), 0 2px 6px rgba(0,0,0,0.15);
}

[data-dice-skin="ornate"] .pip {
  background: radial-gradient(circle, #0fa85c, #0d6b3a);
  box-shadow: 0 0 4px rgba(13, 107, 58, 0.5);
}

/* Dark mode */
[data-theme="dark"] [data-dice-skin="ornate"] .die {
  background: linear-gradient(145deg, #8a8a96, #a0a0ac, #929298);
  border-image: linear-gradient(145deg, #cd8e5a, #e0a870, #cd8e5a) 1;
  box-shadow: inset 0 1px 3px rgba(255,255,255,0.2), 0 2px 6px rgba(0,0,0,0.4);
}

[data-theme="dark"] [data-dice-skin="ornate"] .pip {
  background: radial-gradient(circle, #33b172, #22583a);
  box-shadow: 0 0 5px rgba(61, 220, 132, 0.5);
}

/* --- Bronze: dark body + bronze spherical pips --- */
/* Light mode */
[data-dice-skin="bronze"] .die {
  background: linear-gradient(145deg, #3a3a42, #2a2a32, #333338);
  border-color: #4a4a52;
  border-width: 2px;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.6);
}

[data-dice-skin="bronze"] .pip {
  background: radial-gradient(circle at 35% 35%, #d4a76a, #c9935a, #8b6914);
  box-shadow: 1px 2px 3px rgba(0,0,0,0.5), inset -1px -1px 2px rgba(0,0,0,0.3);
  border-radius: 50%;
}

/* Dark mode */
[data-theme="dark"] [data-dice-skin="bronze"] .die {
  background: linear-gradient(145deg, #28282e, #1e1e24, #2d2d34);
  border-color: #3e3e48;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.8);
}

[data-theme="dark"] [data-dice-skin="bronze"] .pip {
  background: radial-gradient(circle at 35% 35%, #e0b878, #daa86c, #a07840);
  box-shadow: 1px 2px 3px rgba(0,0,0,0.6), inset -1px -1px 2px rgba(0,0,0,0.3);
}

/* --- Marble: white marble + silver chain border + lapis blue pips --- */
/* Light mode */
[data-dice-skin="marble"] .die {
  background: linear-gradient(135deg, #f5f5f0, #e8e6e0, #eeedea);
  border: 3px double #a8a8b0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

[data-dice-skin="marble"] .pip {
  background: radial-gradient(circle at 40% 40%, #3a5fcd, #1f3d7a);
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

/* Dark mode */
[data-theme="dark"] [data-dice-skin="marble"] .die {
  background: linear-gradient(135deg, #d0cfc8, #bfbdb6, #c8c7c2);
  border: 3px double #b8b8c2;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

[data-theme="dark"] [data-dice-skin="marble"] .pip {
  background: radial-gradient(circle at 40% 40%, #3050b0, #1a3570);
  box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

/* --- Crimson: lacquer red + rose gold border + calligraphy numbers --- */
/* Light mode */
[data-dice-skin="crimson"] .die {
  background: linear-gradient(145deg, #c0272d, #a01520, #b52228);
  border: 2px solid #c4917a;
  box-shadow: inset 0 1px 4px rgba(0,0,0,0.3), 0 2px 6px rgba(160,21,32,0.3);
}

[data-dice-skin="crimson"] .pip {
  display: none;
}

.crimson-char {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: clamp(22px, 6vw, 32px);
  font-weight: 700;
  color: #1a0a08;
  font-family: 'Noto Serif', 'Times New Roman', serif;
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
  line-height: 1;
}

/* Dark mode */
[data-theme="dark"] [data-dice-skin="crimson"] .die {
  background: linear-gradient(145deg, #9e1a20, #82101a, #921822);
  border-color: #d4a18a;
  box-shadow: inset 0 1px 4px rgba(0,0,0,0.5), 0 2px 6px rgba(130,16,26,0.4);
}

[data-theme="dark"] [data-dice-skin="crimson"] .crimson-char {
  color: #f0e0d0;
  text-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

/* --- Hologram: translucent + neon glow + circuit pips --- */
/* Light mode */
[data-dice-skin="hologram"] .die {
  background: linear-gradient(145deg, rgba(200, 210, 230, 0.55), rgba(180, 195, 220, 0.45));
  border: 2px solid rgba(0, 210, 230, 0.40);
  box-shadow: 0 0 8px rgba(0, 188, 212, 0.15), inset 0 0 8px rgba(0, 188, 212, 0.05);
}

[data-dice-skin="hologram"] .pip {
  background: #008b8b;
  box-shadow: 0 0 5px rgba(0, 139, 139, 0.6), 0 0 10px rgba(0, 139, 139, 0.2);
  border: 1px solid rgba(0, 139, 139, 0.3);
}

/* Dark mode */
[data-theme="dark"] [data-dice-skin="hologram"] .die {
  background: linear-gradient(145deg, rgba(30, 40, 60, 0.65), rgba(20, 30, 50, 0.55));
  border-color: rgba(0, 229, 255, 0.50);
  box-shadow: 0 0 10px rgba(0, 229, 255, 0.20), inset 0 0 10px rgba(0, 229, 255, 0.05);
}

[data-theme="dark"] [data-dice-skin="hologram"] .pip {
  background: #00e5ff;
  box-shadow: 0 0 6px rgba(0, 229, 255, 0.8), 0 0 12px rgba(0, 229, 255, 0.3);
  border-color: rgba(0, 229, 255, 0.4);
}

/* ----- Circuit skin (Bot Basic) ----- */
[data-dice-skin="circuit"] .die {
  background:
    linear-gradient(0deg, transparent 48%, rgba(160, 140, 60, 0.18) 48%, rgba(160, 140, 60, 0.18) 52%, transparent 52%),
    linear-gradient(90deg, transparent 48%, rgba(160, 140, 60, 0.18) 48%, rgba(160, 140, 60, 0.18) 52%, transparent 52%),
    linear-gradient(90deg, transparent 20%, rgba(160, 140, 60, 0.10) 20%, rgba(160, 140, 60, 0.10) 21%, transparent 21%),
    linear-gradient(0deg, transparent 25%, rgba(160, 140, 60, 0.10) 25%, rgba(160, 140, 60, 0.10) 26%, transparent 26%),
    linear-gradient(90deg, transparent 75%, rgba(160, 140, 60, 0.10) 75%, rgba(160, 140, 60, 0.10) 76%, transparent 76%),
    linear-gradient(0deg, transparent 78%, rgba(160, 140, 60, 0.10) 78%, rgba(160, 140, 60, 0.10) 79%, transparent 79%),
    radial-gradient(circle at 10% 15%, rgba(160, 140, 60, 0.12) 2px, transparent 2px),
    radial-gradient(circle at 88% 82%, rgba(160, 140, 60, 0.12) 2px, transparent 2px),
    radial-gradient(circle at 15% 85%, rgba(160, 140, 60, 0.10) 1.5px, transparent 1.5px),
    radial-gradient(circle at 85% 18%, rgba(160, 140, 60, 0.10) 1.5px, transparent 1.5px),
    linear-gradient(145deg, #2a3a2e, #1e2e24);
  border: 2px solid rgba(180, 160, 80, 0.5);
  box-shadow: 0 0 6px rgba(180, 160, 80, 0.15), inset 0 1px 2px rgba(0, 0, 0, 0.3);
}
[data-dice-skin="circuit"] .pip {
  background: radial-gradient(circle, #80d4ff, #2196f3);
  box-shadow: 0 0 6px rgba(33, 150, 243, 0.7), 0 0 12px rgba(33, 150, 243, 0.3);
  border: 1px solid rgba(100, 200, 255, 0.4);
}
[data-theme="dark"] [data-dice-skin="circuit"] .die {
  background:
    linear-gradient(0deg, transparent 48%, rgba(180, 160, 70, 0.22) 48%, rgba(180, 160, 70, 0.22) 52%, transparent 52%),
    linear-gradient(90deg, transparent 48%, rgba(180, 160, 70, 0.22) 48%, rgba(180, 160, 70, 0.22) 52%, transparent 52%),
    linear-gradient(90deg, transparent 20%, rgba(180, 160, 70, 0.13) 20%, rgba(180, 160, 70, 0.13) 21%, transparent 21%),
    linear-gradient(0deg, transparent 25%, rgba(180, 160, 70, 0.13) 25%, rgba(180, 160, 70, 0.13) 26%, transparent 26%),
    linear-gradient(90deg, transparent 75%, rgba(180, 160, 70, 0.13) 75%, rgba(180, 160, 70, 0.13) 76%, transparent 76%),
    linear-gradient(0deg, transparent 78%, rgba(180, 160, 70, 0.13) 78%, rgba(180, 160, 70, 0.13) 79%, transparent 79%),
    radial-gradient(circle at 10% 15%, rgba(180, 160, 70, 0.16) 2px, transparent 2px),
    radial-gradient(circle at 88% 82%, rgba(180, 160, 70, 0.16) 2px, transparent 2px),
    radial-gradient(circle at 15% 85%, rgba(180, 160, 70, 0.13) 1.5px, transparent 1.5px),
    radial-gradient(circle at 85% 18%, rgba(180, 160, 70, 0.13) 1.5px, transparent 1.5px),
    linear-gradient(145deg, #1a2a1e, #0e1e14);
  border-color: rgba(200, 180, 90, 0.6);
  box-shadow: 0 0 8px rgba(200, 180, 90, 0.2), inset 0 1px 2px rgba(0, 0, 0, 0.5);
}
[data-theme="dark"] [data-dice-skin="circuit"] .pip {
  background: radial-gradient(circle, #b0e0ff, #42a5f5);
  box-shadow: 0 0 8px rgba(66, 165, 245, 0.8), 0 0 16px rgba(66, 165, 245, 0.4);
  border-color: rgba(130, 210, 255, 0.5);
}

/* ----- Carbon skin (Bot Gambler) ----- */
[data-dice-skin="carbon"] .die {
  background:
    repeating-linear-gradient(
      45deg,
      transparent,
      transparent 3px,
      rgba(255, 255, 255, 0.03) 3px,
      rgba(255, 255, 255, 0.03) 4px
    ),
    repeating-linear-gradient(
      -45deg,
      transparent,
      transparent 3px,
      rgba(255, 255, 255, 0.04) 3px,
      rgba(255, 255, 255, 0.04) 4px
    ),
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 6px,
      rgba(0, 0, 0, 0.08) 6px,
      rgba(0, 0, 0, 0.08) 7px
    ),
    linear-gradient(145deg, #3a3a3e, #28282c);
  border: 2px solid rgba(100, 100, 110, 0.5);
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.2), inset 0 1px 2px rgba(0, 0, 0, 0.3);
}
[data-dice-skin="carbon"] .pip {
  background: linear-gradient(180deg, #ffb347, #e67e22);
  box-shadow: 0 0 5px rgba(230, 126, 34, 0.6), 0 0 10px rgba(230, 126, 34, 0.2);
  border: 1px solid rgba(255, 180, 70, 0.4);
  border-radius: 20%;
  width: 55%;
  height: 85%;
}
[data-theme="dark"] [data-dice-skin="carbon"] .die {
  background:
    repeating-linear-gradient(
      45deg,
      transparent,
      transparent 3px,
      rgba(255, 255, 255, 0.04) 3px,
      rgba(255, 255, 255, 0.04) 4px
    ),
    repeating-linear-gradient(
      -45deg,
      transparent,
      transparent 3px,
      rgba(255, 255, 255, 0.05) 3px,
      rgba(255, 255, 255, 0.05) 4px
    ),
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 6px,
      rgba(0, 0, 0, 0.10) 6px,
      rgba(0, 0, 0, 0.10) 7px
    ),
    linear-gradient(145deg, #2a2a2e, #1a1a1e);
  border-color: rgba(120, 120, 130, 0.6);
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.3), inset 0 1px 2px rgba(0, 0, 0, 0.5);
}
[data-theme="dark"] [data-dice-skin="carbon"] .pip {
  background: linear-gradient(180deg, #ffc362, #f0932b);
  box-shadow: 0 0 7px rgba(240, 147, 43, 0.8), 0 0 14px rgba(240, 147, 43, 0.3);
  border-color: rgba(255, 195, 98, 0.5);
  border-radius: 20%;
  width: 55%;
  height: 85%;
}

/* --- Banana: image-based dice skin --- */
[data-dice-skin="banana"] .die {
  background: #eadfd9;
  border: none;
  box-shadow: none;
  padding: 0;
  display: block;
  overflow: visible;
  border-radius: 12px;
}
[data-dice-skin="banana"] .die .banana-die-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  border-radius: 12px;
}
[data-dice-skin="banana"] .pip { display: none; }
[data-theme="dark"] [data-dice-skin="banana"] .die {
  background: #eadfd9;
  border: none;
  box-shadow: none;
}

/* --- Wave: image-based dice skin --- */
[data-dice-skin="wave"] .die {
  background: #c8dce8;
  border: none;
  box-shadow: none;
  padding: 0;
  display: block;
  overflow: visible;
  border-radius: 8px;
}
[data-dice-skin="wave"] .die .wave-die-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  border-radius: 8px;
}
[data-dice-skin="wave"] .pip { display: none; }
[data-theme="dark"] [data-dice-skin="wave"] .die {
  background: #c8dce8;
  border: none;
  box-shadow: inset 0 0 0 2px #8aaabe;
}

/* --- Fire: image-based dice skin --- */
[data-dice-skin="fire"] .die {
  background: #b5712a;
  border: none;
  box-shadow: none;
  padding: 0;
  display: block;
  overflow: visible;
  border-radius: 12px;
}
[data-dice-skin="fire"] .die .fire-die-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  border-radius: 12px;
  box-shadow: 0 0 0 2px #8a5a1e;
}
[data-dice-skin="fire"] .pip { display: none; }
[data-theme="dark"] [data-dice-skin="fire"] .die {
  background: #b5712a;
  border: none;
  box-shadow: none;
}
[data-theme="dark"] [data-dice-skin="fire"] .die .fire-die-img {
  box-shadow: 0 0 0 2px #a06820;
}

/* --- Dragon: image-based dice skin --- */
[data-dice-skin="dragon"] .die {
  background: #1a1a2e;
  border-color: #c08430;
  padding: 0;
  display: block;
  overflow: visible;
  border-radius: 12px;
}
[data-dice-skin="dragon"] .die .dragon-die-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 10px;
}
[data-dice-skin="dragon"] .pip { display: none; }
[data-theme="dark"] [data-dice-skin="dragon"] .die {
  background: #1a1a2e;
  border-color: #d4a04a;
  box-shadow: 0 0 8px rgba(212, 160, 74, 0.4);
}

/* --- Flower: image-based dice skin --- */
[data-dice-skin="flower"] .die {
  background: #c8dce8;
  border-color: #e08090;
  padding: 0;
  display: block;
  overflow: visible;
  border-radius: 12px;
}
[data-dice-skin="flower"] .die .flower-die-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 10px;
}
[data-dice-skin="flower"] .pip { display: none; }
[data-theme="dark"] [data-dice-skin="flower"] .die {
  background: #c8dce8;
  border-color: #f0a0b0;
  box-shadow: 0 0 8px rgba(240, 160, 176, 0.4);
}

/* --- Siru: image-based dice skin --- */
[data-dice-skin="siru"] .die {
  background: #faf1e4;
  border: none;
  box-shadow: none;
  padding: 0;
  display: block;
  overflow: visible;
  border-radius: 8px;
}
[data-dice-skin="siru"] .die .siru-die-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  border-radius: 8px;
}
[data-dice-skin="siru"] .pip { display: none; }
[data-theme="dark"] [data-dice-skin="siru"] .die {
  background: #faf1e4;
  border: none;
  box-shadow: inset 0 0 0 2px #8a6a4e;
}

/* --- Star Skin --- */
[data-dice-skin="star"] .die {
  background: linear-gradient(135deg, #1a1a2e, #16213e);
  border-color: #e2b04a;
  grid-template-rows: repeat(3, minmax(0, 1fr));
  grid-template-columns: repeat(3, minmax(0, 1fr));
  place-items: center;
}
[data-dice-skin="star"] .pip {
  border-radius: 0;
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
  width: clamp(10px, 2.5vw, 14px);
  height: clamp(10px, 2.5vw, 14px);
}
[data-dice-skin="star"] .die[data-value="1"] .pip {
  background: linear-gradient(135deg, #ffecd2, #fcb69f, #ee8b60);
  filter: drop-shadow(0 0 0 #ee8b60) drop-shadow(0 0 0 #ee8b60) drop-shadow(0 0 4px rgba(252, 182, 159, 0.8));
  width: clamp(28px, 7vw, 38px); height: clamp(28px, 7vw, 38px);
}
[data-dice-skin="star"] .die[data-value="2"] .pip {
  background: linear-gradient(135deg, #a18cd1, #8360c3, #6335a5);
  filter: drop-shadow(0 0 0 #6335a5) drop-shadow(0 0 0 #6335a5) drop-shadow(0 0 3px rgba(131, 96, 195, 0.7));
  width: clamp(16px, 4vw, 20px); height: clamp(16px, 4vw, 20px);
}
[data-dice-skin="star"] .die[data-value="3"] .pip {
  background: linear-gradient(135deg, #c3f0e8, #a7ffe4, #56ccb2);
  filter: drop-shadow(0 0 0 #56ccb2) drop-shadow(0 0 0 #56ccb2) drop-shadow(0 0 3px rgba(167, 255, 228, 0.6));
  width: clamp(14px, 3.5vw, 18px); height: clamp(14px, 3.5vw, 18px);
}
[data-dice-skin="star"] .die[data-value="4"] .pip {
  background: linear-gradient(135deg, #fbc2eb, #e08abf, #c0609a);
  filter: drop-shadow(0 0 0 #c0609a) drop-shadow(0 0 0 #c0609a) drop-shadow(0 0 3px rgba(224, 138, 191, 0.7));
  width: clamp(13px, 3.2vw, 16px); height: clamp(13px, 3.2vw, 16px);
}
[data-dice-skin="star"] .die[data-value="5"] .pip {
  background: linear-gradient(135deg, #89c4f4, #5b9bd5, #3a76b0);
  filter: drop-shadow(0 0 0 #3a76b0) drop-shadow(0 0 0 #3a76b0) drop-shadow(0 0 3px rgba(91, 155, 213, 0.7));
  width: clamp(12px, 3vw, 15px); height: clamp(12px, 3vw, 15px);
}
[data-dice-skin="star"] .die[data-value="6"] .pip {
  background: linear-gradient(135deg, #fff1c1, #f0d68a, #d4af37);
  filter: drop-shadow(0 0 0 #d4af37) drop-shadow(0 0 0 #d4af37) drop-shadow(0 0 3px rgba(240, 214, 138, 0.7));
}
[data-theme="dark"] [data-dice-skin="star"] .die {
  background: linear-gradient(135deg, #0d0d1a, #111827);
  border-color: #f5c542;
}

/* Star skin preview */
.skin-preview-die[data-dice-skin="star"] {
  background: linear-gradient(135deg, #1a1a2e, #16213e);
  border-color: #e2b04a;
}
.skin-preview-die[data-dice-skin="star"] .mini-pip {
  background: #5b9bd5;
  border-radius: 0;
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}
[data-theme="dark"] .skin-preview-die[data-dice-skin="star"] {
  background: linear-gradient(135deg, #0d0d1a, #111827);
  border-color: #f5c542;
}
[data-theme="dark"] .skin-preview-die[data-dice-skin="star"] .mini-pip {
  background: #89c4f4;
}

/* ===== Skin Selector (Lobby) ===== */
.skin-selector {
  margin-top: 20px;
  text-align: center;
  padding: 20px !important;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
}

[data-theme="dark"] .skin-selector {
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
}

.skin-section {
  margin-top: 14px;
}

.skin-divider {
  height: 1px;
  background: var(--border);
  margin: 14px 0 0;
}

.skin-section-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 10px;
}

.skin-selector-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 12px;
}

.skin-selector-label {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
}

.skin-unlock-count {
  font-size: 0.8rem;
  color: var(--text-muted);
  background: var(--surface);
  padding: 2px 8px;
  border-radius: 10px;
}

.skin-unlock-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: -4px 0 10px;
  text-align: center;
  line-height: 1.3;
}

.skin-options {
  display: grid;
  /* minmax(0, 1fr): a long label must not widen its column (keeps the 4 columns equal on phones) */
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.skin-divider {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0 2px;
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.skin-divider::before,
.skin-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.skin-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius);
  border: 2px solid transparent;
  transition: border-color 0.2s, opacity 0.2s;
  position: relative;
  min-width: 0;
}

.skin-option:hover:not(.locked) {
  border-color: var(--border);
}

.skin-option.active {
  border-color: var(--accent);
}

/* Skin-specific active selection borders — Light mode */
.skin-option.active[data-skin-id="ornate"] { border-color: #b87333; }
.skin-option.active[data-skin-id="bronze"] { border-color: #a07840; }
.skin-option.active[data-skin-id="marble"] { border-color: #8888a0; }
.skin-option.active[data-skin-id="crimson"] { border-color: #c0272d; }
.skin-option.active[data-skin-id="hologram"] { border-color: #00acc1; }
.skin-option.active[data-skin-id="circuit"] { border-color: #2196f3; }
.skin-option.active[data-skin-id="carbon"] { border-color: #e67e22; }
.skin-option.active[data-skin-id="banana"] { border-color: #e0c060; }
.skin-option.active[data-skin-id="wave"] { border-color: #4a90b8; }
.skin-option.active[data-skin-id="fire"] { border-color: #e67e22; }
.skin-option.active[data-skin-id="dragon"] { border-color: #c08430; }
.skin-option.active[data-skin-id="flower"] { border-color: #e08090; }
.skin-option.active[data-skin-id="siru"] { border-color: #8a5c3a; }
.skin-option.active[data-skin-id="star"] { border-color: #fcb69f; }

/* Skin-specific active selection borders — Dark mode */
[data-theme="dark"] .skin-option.active[data-skin-id="ornate"] { border-color: #cd8e5a; }
[data-theme="dark"] .skin-option.active[data-skin-id="bronze"] { border-color: #c49332; }
[data-theme="dark"] .skin-option.active[data-skin-id="marble"] { border-color: #a0a0b8; }
[data-theme="dark"] .skin-option.active[data-skin-id="crimson"] { border-color: #d43a3a; }
[data-theme="dark"] .skin-option.active[data-skin-id="hologram"] { border-color: #00e5ff; }
[data-theme="dark"] .skin-option.active[data-skin-id="circuit"] { border-color: #42a5f5; }
[data-theme="dark"] .skin-option.active[data-skin-id="carbon"] { border-color: #f0932b; }
[data-theme="dark"] .skin-option.active[data-skin-id="banana"] { border-color: #f0d870; }
[data-theme="dark"] .skin-option.active[data-skin-id="wave"] { border-color: #5aa8d0; }
[data-theme="dark"] .skin-option.active[data-skin-id="fire"] { border-color: #f0932b; }
[data-theme="dark"] .skin-option.active[data-skin-id="dragon"] { border-color: #d4a04a; }
[data-theme="dark"] .skin-option.active[data-skin-id="flower"] { border-color: #f0a0b0; }
[data-theme="dark"] .skin-option.active[data-skin-id="siru"] { border-color: #c89b6a; }
[data-theme="dark"] .skin-option.active[data-skin-id="star"] { border-color: #fcb69f; }

.skin-option.locked {
  cursor: default;
  opacity: 0.4;
}

.skin-name {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* Shimmer effect for skins with special celebration effects */
.skin-option:not(.locked)[data-skin-id="banana"] .skin-name,
.skin-option:not(.locked)[data-skin-id="fire"] .skin-name,
.skin-option:not(.locked)[data-skin-id="dragon"] .skin-name,
.skin-option:not(.locked)[data-skin-id="flower"] .skin-name,
.skin-option:not(.locked)[data-skin-id="wave"] .skin-name,
.skin-option:not(.locked)[data-skin-id="siru"] .skin-name,
.skin-option:not(.locked)[data-skin-id="star"] .skin-name {
  background: linear-gradient(90deg, var(--text-muted) 0%, var(--text-muted) 35%, #ffd700 50%, var(--text-muted) 65%, var(--text-muted) 100%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: skin-name-shimmer 2.5s ease-in-out infinite;
}

@keyframes skin-name-shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

.lock-overlay {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  font-size: 14px;
  filter: grayscale(1);
}

.lock-progress {
  display: block;
  font-size: 0.6rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.2;
  margin-top: 1px;
  white-space: nowrap; /* one line; may overhang into the grid gap (centered) without widening the column */
}

/* Mini die preview in skin selector */
.skin-preview-die {
  width: 40px;
  height: 40px;
  border-radius: 4px;
  display: grid;
  grid-template-rows: repeat(3, 1fr);
  grid-template-columns: repeat(3, 1fr);
  padding: 4px;
  position: relative;
  background: var(--die-bg);
  border: 2px solid var(--die-border);
}

/* Preview skin overrides — Light mode */
.skin-preview-die[data-dice-skin="ornate"] {
  background: linear-gradient(145deg, #e8e8ec, #d8d8e0);
  border: 3px solid #b87333;
}
.skin-preview-die[data-dice-skin="ornate"] .mini-pip { background: #0d6b3a; }

.skin-preview-die[data-dice-skin="bronze"] {
  background: linear-gradient(145deg, #3a3a42, #2a2a32);
  border-color: #4a4a52;
}
.skin-preview-die[data-dice-skin="bronze"] .mini-pip {
  background: radial-gradient(circle at 35% 35%, #d4a76a, #c9935a);
}

.skin-preview-die[data-dice-skin="marble"] {
  background: linear-gradient(135deg, #f5f5f0, #e8e6e0);
  border: 3px double #a8a8b0;
}
.skin-preview-die[data-dice-skin="marble"] .mini-pip { background: #1f3d7a; }

.skin-preview-die[data-dice-skin="crimson"] {
  background: linear-gradient(145deg, #c0272d, #a01520);
  border-color: #c4917a;
}
.skin-preview-die[data-dice-skin="crimson"] .crimson-char {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 18px;
  font-weight: 700;
  color: #1a0a08;
  font-family: 'Noto Serif', 'Times New Roman', serif;
  line-height: 1;
}

.skin-preview-die[data-dice-skin="hologram"] {
  background: linear-gradient(145deg, rgba(200, 210, 230, 0.55), rgba(180, 195, 220, 0.45));
  border-color: rgba(0, 210, 230, 0.40);
}
.skin-preview-die[data-dice-skin="hologram"] .mini-pip {
  background: #008b8b;
  box-shadow: 0 0 3px rgba(0, 139, 139, 0.5);
}
.skin-preview-die[data-dice-skin="circuit"] {
  background: linear-gradient(145deg, #2a3a2e, #1e2e24);
  border-color: rgba(180, 160, 80, 0.5);
}
.skin-preview-die[data-dice-skin="circuit"] .mini-pip {
  background: radial-gradient(circle, #80d4ff, #2196f3);
  box-shadow: 0 0 4px rgba(33, 150, 243, 0.6);
}
.skin-preview-die[data-dice-skin="carbon"] {
  background: linear-gradient(145deg, #3a3a3e, #28282c);
  border-color: rgba(100, 100, 110, 0.5);
}
.skin-preview-die[data-dice-skin="carbon"] .mini-pip {
  background: linear-gradient(180deg, #ffb347, #e67e22);
  box-shadow: 0 0 4px rgba(230, 126, 34, 0.5);
  border-radius: 20%;
}
.skin-preview-die[data-dice-skin="banana"] {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
  display: block;
  overflow: hidden;
}
.skin-preview-die[data-dice-skin="banana"] .banana-preview {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.skin-preview-die[data-dice-skin="banana"] .mini-pip { display: none; }
.skin-preview-die[data-dice-skin="wave"] {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
  display: block;
  overflow: hidden;
}
.skin-preview-die[data-dice-skin="wave"] .wave-preview {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.skin-preview-die[data-dice-skin="wave"] .mini-pip { display: none; }
.skin-preview-die[data-dice-skin="fire"] {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
  display: block;
  overflow: visible;
}
.skin-preview-die[data-dice-skin="fire"] .fire-preview {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  box-shadow: 0 0 0 1.5px #8a5a1e;
  border-radius: 4px;
}
.skin-preview-die[data-dice-skin="fire"] .mini-pip { display: none; }

.skin-preview-die[data-dice-skin="dragon"] {
  background: #1a1a2e;
  border: 2px solid #c08430;
  box-shadow: none;
  padding: 0;
  display: block;
  overflow: hidden;
}
.skin-preview-die[data-dice-skin="dragon"] .dragon-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 4px;
}
.skin-preview-die[data-dice-skin="dragon"] .mini-pip { display: none; }

.skin-preview-die[data-dice-skin="flower"] {
  background: #c8dce8;
  border: 2px solid #e08090;
  box-shadow: none;
  padding: 0;
  display: block;
  overflow: hidden;
}
.skin-preview-die[data-dice-skin="flower"] .flower-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 4px;
}
.skin-preview-die[data-dice-skin="flower"] .mini-pip { display: none; }

.skin-preview-die[data-dice-skin="siru"] {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
  display: block;
  overflow: hidden;
}
.skin-preview-die[data-dice-skin="siru"] .siru-preview {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.skin-preview-die[data-dice-skin="siru"] .mini-pip { display: none; }

/* Preview skin overrides — Dark mode */
[data-theme="dark"] .skin-preview-die[data-dice-skin="ornate"] {
  background: linear-gradient(145deg, #8a8a96, #929298);
  border-color: #cd8e5a;
}
[data-theme="dark"] .skin-preview-die[data-dice-skin="ornate"] .mini-pip { background: #3ddc84; }

[data-theme="dark"] .skin-preview-die[data-dice-skin="bronze"] {
  background: linear-gradient(145deg, #28282e, #1e1e24);
  border-color: #3e3e48;
}
[data-theme="dark"] .skin-preview-die[data-dice-skin="bronze"] .mini-pip {
  background: radial-gradient(circle at 35% 35%, #e0b878, #daa86c);
}

[data-theme="dark"] .skin-preview-die[data-dice-skin="marble"] {
  background: linear-gradient(135deg, #d0cfc8, #bfbdb6);
  border: 3px double #b8b8c2;
}
[data-theme="dark"] .skin-preview-die[data-dice-skin="marble"] .mini-pip { background: #1a3570; }

[data-theme="dark"] .skin-preview-die[data-dice-skin="crimson"] {
  background: linear-gradient(145deg, #9e1a20, #82101a);
  border-color: #d4a18a;
}
[data-theme="dark"] .skin-preview-die[data-dice-skin="crimson"] .crimson-char {
  color: #f0e0d0;
}

[data-theme="dark"] .skin-preview-die[data-dice-skin="hologram"] {
  background: linear-gradient(145deg, rgba(30, 40, 60, 0.65), rgba(20, 30, 50, 0.55));
  border-color: rgba(0, 229, 255, 0.50);
  box-shadow: 0 0 6px rgba(0, 229, 255, 0.2);
}
[data-theme="dark"] .skin-preview-die[data-dice-skin="hologram"] .mini-pip {
  background: #00e5ff;
  box-shadow: 0 0 4px rgba(0, 229, 255, 0.6);
}
[data-theme="dark"] .skin-preview-die[data-dice-skin="circuit"] {
  background: linear-gradient(145deg, #1a2a1e, #0e1e14);
  border-color: rgba(200, 180, 90, 0.6);
  box-shadow: 0 0 6px rgba(200, 180, 90, 0.2);
}
[data-theme="dark"] .skin-preview-die[data-dice-skin="circuit"] .mini-pip {
  background: radial-gradient(circle, #b0e0ff, #42a5f5);
  box-shadow: 0 0 5px rgba(66, 165, 245, 0.7);
}
[data-theme="dark"] .skin-preview-die[data-dice-skin="carbon"] {
  background: linear-gradient(145deg, #2a2a2e, #1a1a1e);
  border-color: rgba(120, 120, 130, 0.6);
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.3);
}
[data-theme="dark"] .skin-preview-die[data-dice-skin="carbon"] .mini-pip {
  background: linear-gradient(180deg, #ffc362, #f0932b);
  box-shadow: 0 0 5px rgba(240, 147, 43, 0.7);
  border-radius: 20%;
}
[data-theme="dark"] .skin-preview-die[data-dice-skin="banana"] {
  background: transparent;
  border: none;
  box-shadow: none;
}
[data-theme="dark"] .skin-preview-die[data-dice-skin="wave"] {
  background: transparent;
  border: none;
  box-shadow: none;
}
[data-theme="dark"] .skin-preview-die[data-dice-skin="fire"] {
  background: transparent;
  border: none;
  box-shadow: none;
}
[data-theme="dark"] .skin-preview-die[data-dice-skin="dragon"] {
  border-color: #d4a04a;
}
[data-theme="dark"] .skin-preview-die[data-dice-skin="flower"] {
  border-color: #f0a0b0;
}
[data-theme="dark"] .skin-preview-die[data-dice-skin="siru"] {
  background: transparent;
  border: none;
  box-shadow: none;
}

.mini-pip {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--pip-color);
  align-self: center;
  justify-self: center;
}

.mini-pip.hidden {
  visibility: hidden;
}

/* ===== Emote System ===== */
.emote-bar {
  position: relative;
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
  gap: 8px;
}

.emote-quick {
  display: flex;
  gap: 6px;
}

.emote-quick-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 4px 10px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
  color: var(--text);
  white-space: nowrap;
}

.emote-quick-btn:hover {
  background: var(--accent-light);
  border-color: var(--accent);
}

.emote-quick-btn:active {
  transform: scale(0.93);
}

.btn-emote-toggle {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 16px;
  font-size: 1.1rem;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
  color: var(--text);
}

.btn-emote-toggle:hover {
  background: var(--surface-hover);
  border-color: var(--accent);
}

.emote-picker {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  z-index: 50;
  width: min(340px, 90vw);
  max-height: 260px;
  overflow-y: auto;
}

.emote-picker.hidden {
  display: none;
}

.emote-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 6px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
  color: var(--text);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.emote-btn:hover {
  background: var(--accent-light);
  border-color: var(--accent);
}

.emote-btn:active {
  transform: scale(0.95);
}

.emote-bubble {
  position: absolute;
  background: var(--accent);
  color: #fff;
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  z-index: 80;
  text-align: center;
  white-space: nowrap;
  animation: emotePopIn 0.3s ease;
  pointer-events: none;
}

.emote-bubble.hidden {
  display: none;
}

@keyframes emotePopIn {
  0% { opacity: 0; scale: 0.5; }
  70% { scale: 1.1; }
  100% { opacity: 1; scale: 1; }
}

/* ===== Bot Thinking Indicator ===== */
.bot-thinking {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  gap: 4px;
  align-items: center;
  z-index: 80;
  pointer-events: none;
}
.bot-thinking.hidden {
  display: none;
}
.thinking-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent, #5b6eae);
  animation: thinkingPulse 1.4s ease-in-out infinite;
}
.thinking-dot:nth-child(2) { animation-delay: 0.2s; }
.thinking-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes thinkingPulse {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1.2); }
}

/* ===== Scorecard ===== */
.scorecard {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: visible;
}

.scorecard table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  table-layout: fixed;
}

.scorecard th,
.scorecard td {
  padding: 8px 12px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}

.scorecard th {
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scorecard th.current-turn {
  color: var(--text);
  font-weight: 800;
}

.scorecard .category-name {
  text-align: left;
  font-weight: 500;
  white-space: nowrap;
}

.scorecard .score-cell {
  min-width: 48px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.scorecard .score-cell.mine {
  color: var(--score-mine);
}

.scorecard .score-cell.opponent {
  color: var(--score-opponent);
}

.scorecard .score-cell.preview {
  color: var(--score-preview);
  cursor: pointer;
}

.scorecard .score-cell.preview:hover {
  background: var(--accent-light);
  color: var(--accent);
}

.scorecard .score-cell.preview-opp {
  color: var(--text-muted);
  cursor: default;
}

.scorecard .score-cell.filled {
  cursor: default;
}

.scorecard .score-cell.preview {
  position: relative;
}

.scorecard .score-cell.pending {
  background: var(--accent-light);
  color: var(--accent);
}

.scorecard .score-cell.loading {
  background: var(--accent-light);
  pointer-events: none;
}

.scorecard .score-cell.loading .btn-dice-spinner {
  font-size: 0.85rem;
}

/* Score confirm hint popup */
.score-confirm-hint {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 10;
  animation: hintFadeIn 0.2s ease;
}

.score-confirm-hint.fade-out {
  animation: hintFadeOut 0.3s ease forwards;
}

@keyframes hintFadeIn {
  from { opacity: 0; transform: translateX(-50%) translateY(4px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes hintFadeOut {
  from { opacity: 1; }
  to   { opacity: 0; }
}

.scorecard .score-cell.last-scored {
  font-weight: 800;
  box-shadow: inset 3px 0 0 rgba(74, 108, 247, 0.35);
}

[data-theme="dark"] .scorecard .score-cell.last-scored {
  box-shadow: inset 3px 0 0 rgba(108, 140, 255, 0.35);
}

.scorecard .lower-row td {
  background: var(--accent-light);
}

.scorecard .bonus-row td {
  font-weight: 600;
  background: var(--surface-hover);
}

.scorecard .bonus-row .category-name {
  font-style: italic;
}

.scorecard .total-row td {
  font-weight: 700;
  font-size: 0.95rem;
  background: var(--surface);
  border-top: 2px solid var(--border);
}

.score-entry-flash {
  animation: scoreFlash 0.4s ease;
}

@keyframes scoreFlash {
  0% { background: var(--accent-light); }
  100% { background: transparent; }
}

/* ===== Game Over ===== */
.gameover-card {
  text-align: center;
}

.gameover-card h2 {
  font-size: 1.8rem;
  margin-bottom: 24px;
}

.final-scores {
  margin-bottom: 24px;
}

.final-scores table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.final-scores th,
.final-scores td {
  padding: 10px 16px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}

.final-scores th {
  font-weight: 600;
  color: var(--text-muted);
}

.final-scores .winner-score {
  color: var(--success);
  font-weight: 700;
}

/* ===== Overlay ===== */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
}

.overlay.hidden {
  display: none;
}

.overlay-content {
  background: var(--surface);
  padding: 32px;
  border-radius: var(--radius);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-lg);
}

.overlay-content p {
  white-space: pre-line;
}

/* ===== Tutorial ===== */
.tutorial-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.55);
  pointer-events: none;
}

.tutorial-highlight {
  position: relative !important;
  z-index: 1001 !important;
  border-radius: var(--radius);
  box-shadow: 0 0 0 4px var(--accent);
}


.tutorial-tooltip {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: #ffffff;
  padding: 16px 20px;
  border-radius: var(--radius-lg, 16px);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.35), 0 0 0 3px var(--accent);
  max-width: 320px;
  width: calc(100% - 32px);
  z-index: 10000;
  pointer-events: auto;
  text-align: center;
}
[data-theme="dark"] .tutorial-tooltip {
  background: #1e1e2e;
}

.tutorial-tooltip p {
  margin: 0 0 12px;
  font-size: 0.9rem;
  white-space: pre-line;
  line-height: 1.4;
  color: var(--text);
}

.tutorial-buttons {
  display: flex;
  gap: 10px;
  align-items: stretch;
  justify-content: center;
}

.btn-tutorial-next {
  padding: 8px 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-tutorial-skip {
  padding: 8px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-sub);
  font-size: 0.85rem;
  cursor: pointer;
}

/* Tutorial entry button on login/lobby */
.btn-tutorial {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 0.78rem;
  color: var(--text-sub);
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
  margin-top: 8px;
}
.btn-tutorial:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.tutorial-overlay.hidden,
.tutorial-tooltip.hidden {
  display: none !important;
}

.disconnect-countdown {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--danger);
}

.draw-buttons {
  display: flex;
  gap: 12px;
}

.draw-buttons .btn-primary,
.draw-buttons .btn-secondary {
  padding: 10px 24px;
  font-size: 0.9rem;
  white-space: nowrap;
}

/* ===== Session Notice ===== */
p.session-notice {
  margin-top: 16px;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  opacity: 0.7;
}

/* ===== Rules Overlay ===== */
#overlay-rules {
  pointer-events: none;
}

.rules-content {
  max-width: 360px;
  max-height: 80vh;
  overflow-y: auto;
  text-align: left;
}

.rules-content h3 {
  text-align: center;
  margin-bottom: 12px;
  font-size: 1.1rem;
}

.rules-content table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.rules-content th,
.rules-content td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
}

.rules-content th {
  font-weight: 600;
  color: var(--text-muted);
  text-align: left;
}

.rules-note {
  margin-top: 12px;
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ===== Shortcut Overlay ===== */
#overlay-shortcut {
  pointer-events: none;
}

#overlay-shortcut kbd {
  display: inline-block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  min-width: 1.4em;
  text-align: center;
}

/* ===== Keyboard Focus Highlight ===== */
.score-cell.preview.kb-focus {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  background: var(--accent-light);
  color: var(--accent);
}

.btn-roll.kb-focus {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* ===== Toast ===== */
.toast-container {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--surface);
  color: var(--text);
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  font-size: 0.9rem;
  font-weight: 500;
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
  pointer-events: auto;
  border-left: 3px solid var(--accent);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-16px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-16px); }
}

/* Nickname: full vs short for mobile */
.name-short { display: none; }

/* ===== Responsive ===== */
@media (max-width: 480px) {
  .name-full { display: none; }
  .name-short { display: inline; }
  header {
    padding: 12px 16px 0;
  }

  .header-controls {
    margin-bottom: 6px;
  }

  .screen {
    padding: 0 16px 16px;
  }

  .card {
    padding: 24px 20px;
  }

  .dice-area {
    gap: 6px;
  }

  .btn-roll {
    padding: 0 4px;
    font-size: 0.75rem;
  }

  .scorecard th,
  .scorecard td {
    padding: 6px 8px;
    font-size: 0.8rem;
  }

  .scorecard .score-cell {
    min-width: 36px;
  }

  .mode-options {
    flex-direction: column;
  }
}

/* Narrow phones (Galaxy 360px, Fold cover, SE 1st gen): shrink dice a little so the
   roll button keeps room for a one-line label and the row never overflows. */
@media (max-width: 370px) {
  .dice-roll-row { gap: 8px; }
  .die {
    width: clamp(42px, 13vw, 52px);
    height: clamp(42px, 13vw, 52px);
    padding: 6px;
  }
}

/* ---- Scorecard header 3D mini dice ---- */
.header-die-wrap {
  display: inline-block;
  vertical-align: middle;
  perspective: 90px;
}

.header-die-cube {
  display: inline-block;
  width: 14px;
  height: 14px;
  position: relative;
  top: -2px;
  vertical-align: middle;
  transform-style: preserve-3d;
  margin-right: 6px;
}

.cube-inner {
  display: block;
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
}

.cube-face.skin-preview-die {
  position: absolute;
  width: 14px;
  height: 14px;
  padding: 1px;
  border-width: 1px;
  border-radius: 2px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  outline: 1px solid transparent; /* anti-aliasing trick */
}

.cube-face.skin-preview-die .mini-pip {
  width: 2px;
  height: 2px;
}

.cube-face.skin-preview-die .crimson-char {
  font-size: 7px;
}

.cube-face.skin-preview-die[data-dice-skin="banana"] .mini-pip { display: none; }
.cube-face.skin-preview-die[data-dice-skin="wave"] .mini-pip { display: none; }
.cube-face.skin-preview-die[data-dice-skin="fire"] .mini-pip { display: none; }
.cube-face.skin-preview-die[data-dice-skin="flower"] .mini-pip { display: none; }
.cube-face.skin-preview-die[data-dice-skin="flower"] .flower-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  box-shadow: 0 0 0 1.5px #e08090;
}
.cube-face.skin-preview-die[data-dice-skin="flower"] {
  background: transparent;
  border: none;
  padding: 0;
  overflow: hidden;
  display: block;
}
[data-theme="dark"] .cube-face.skin-preview-die[data-dice-skin="flower"] .flower-preview {
  box-shadow: 0 0 0 1.5px #f0a0b0;
}
.cube-face.skin-preview-die[data-dice-skin="dragon"] .mini-pip { display: none; }
.cube-face.skin-preview-die[data-dice-skin="dragon"] .dragon-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  box-shadow: 0 0 0 1.5px #c08430;
}
.cube-face.skin-preview-die[data-dice-skin="dragon"] {
  background: transparent;
  border: none;
  padding: 0;
  overflow: hidden;
  display: block;
}
[data-theme="dark"] .cube-face.skin-preview-die[data-dice-skin="dragon"] .dragon-preview {
  box-shadow: 0 0 0 1.5px #d4a04a;
}
.cube-face.skin-preview-die[data-dice-skin="fire"] .fire-preview {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  box-shadow: 0 0 0 1.5px #8a5a1e;
  border-radius: 4px;
}
.cube-face.skin-preview-die[data-dice-skin="fire"] {
  background: transparent;
  border: none;
  padding: 0;
  overflow: hidden;
}
.cube-face.skin-preview-die[data-dice-skin="wave"] .wave-preview {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.cube-face.skin-preview-die[data-dice-skin="wave"] {
  background: transparent;
  border: none;
  padding: 0;
  overflow: hidden;
}
.cube-face.skin-preview-die[data-dice-skin="siru"] .mini-pip { display: none; }
.cube-face.skin-preview-die[data-dice-skin="siru"] .siru-preview {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.cube-face.skin-preview-die[data-dice-skin="siru"] {
  background: transparent;
  border: none;
  padding: 0;
  overflow: hidden;
  display: block;
}
.cube-face.skin-preview-die[data-dice-skin="banana"] .banana-preview {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.cube-face.skin-preview-die[data-dice-skin="banana"] {
  background: transparent;
  border: none;
  padding: 0;
  overflow: hidden;
}

/* 6 faces positioned in 3D space */
.cube-face:nth-child(1) { transform: translateZ(7px); }                          /* front */
.cube-face:nth-child(2) { transform: rotateY(180deg) translateZ(7px); }          /* back */
.cube-face:nth-child(3) { transform: rotateY(90deg) translateZ(7px); }           /* right */
.cube-face:nth-child(4) { transform: rotateY(-90deg) translateZ(7px); }          /* left */
.cube-face:nth-child(5) { transform: rotateX(90deg) translateZ(7px); }           /* top */
.cube-face:nth-child(6) { transform: rotateX(-90deg) translateZ(7px); }          /* bottom */

/* Spinning animation for current turn player's header die */
@keyframes die-spin {
  0%   { transform: rotateY(0deg)   rotateX(0deg); }
  50%  { transform: rotateY(180deg) rotateX(180deg); }
  100% { transform: rotateY(360deg) rotateX(360deg); }
}

.header-die-wrap.header-die-spin .cube-inner {
  animation: die-spin 4s linear infinite;
}

/* ===== Mobile: remove 300ms tap delay ===== */
button, .die, .score-cell, .skin-option, .emote-btn {
  touch-action: manipulation;
}

/* ===== Utility Classes (CSP: no inline styles) ===== */
button.btn-full-width { width: 100%; }
.btn-mt-16 { margin-top: 16px; }
.btn-mt-12 { margin-top: 12px; }
.bot-difficulty-mb { margin-bottom: 16px; }

/* ===== Augment mode ===== */
:root {
  --aug-tier1: #2f9e6e;
  --aug-tier2: #4a6cf7;
  --aug-tier3: #c98a12;
  --aug-sealed-bg: rgba(231, 76, 60, 0.12);
}

[data-theme="dark"] {
  --aug-tier1: #4fd39a;
  --aug-tier2: #7d97ff;
  --aug-tier3: #f2b84b;
  --aug-sealed-bg: rgba(255, 107, 107, 0.16);
}

.mode-option-augment .mode-label::before {
  content: "\2726  ";
  color: var(--aug-tier3);
}

/* Two rows (나 / 상대) on a shared grid so both chip lists start at the same x. */
.augment-bar {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  align-items: center;
  column-gap: 8px;
  row-gap: 6px;
  padding: 8px 0 0;
}

.augment-bar.hidden {
  display: none;
}

.aug-row {
  display: contents;
}

.aug-chips {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

/* "다음 증강 / n턴 뒤": right column spanning both rows, centered (only until tier 3). */
.augment-bar.has-next {
  grid-template-columns: max-content minmax(0, 1fr) auto;
}

.aug-next {
  grid-column: 3;
  grid-row: 1 / span 2;
  align-self: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding-left: 4px;
  text-align: center;
  white-space: nowrap;
  line-height: 1.15;
}

.aug-next-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.aug-next-turns {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.aug-row-label,
.aug-empty {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.aug-chip {
  --tier: var(--aug-tier1);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: 0 1 auto;
  min-width: 0;
  padding: 6px 10px;
  min-height: 30px;
  border-radius: 999px;
  border: 1.5px solid var(--tier);
  background: var(--surface);
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}

/* Last-resort squeeze on very narrow screens: truncate instead of wrapping. */
.aug-chip-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.aug-chip .aug-badge {
  flex-shrink: 0;
}

/* Mobile: three chips per player must stay on one line even with the longest picks. */
@media (max-width: 480px) {
  .augment-bar { column-gap: 6px; }
  .aug-chips { gap: 4px; }
  .aug-chip {
    gap: 4px;
    padding: 5px 8px;
    min-height: 28px;
    font-size: 0.74rem;
  }
  .aug-chip .aug-badge {
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    font-size: 0.64rem;
  }
}

@media (max-width: 360px) {
  .augment-bar { column-gap: 5px; }
  .aug-chip {
    gap: 3px;
    padding: 4px 6px;
    font-size: 0.68rem;
  }
  .aug-chip .aug-badge {
    min-width: 14px;
    height: 14px;
    padding: 0 3px;
    font-size: 0.6rem;
  }
  .aug-row-label { font-size: 0.7rem; }
}

.aug-chip.tier-2 { --tier: var(--aug-tier2); }
.aug-chip.tier-3 { --tier: var(--aug-tier3); }

button.aug-chip {
  cursor: pointer;
  font-family: inherit;
  transition: background var(--transition), opacity var(--transition);
}

button.aug-chip:not(:disabled):hover {
  background: var(--surface-hover);
}

button.aug-chip:not(:disabled) {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--tier) 18%, transparent);
}

button.aug-chip:disabled {
  cursor: default;
  opacity: 0.55;
}

.aug-chip.armed,
button.aug-chip.armed:not(:disabled):hover {
  background: var(--tier);
  color: #fff;
}

.aug-chip.spent {
  opacity: 0.4;
  text-decoration: line-through;
}

.aug-chip.opp-chip {
  border-style: dashed;
}

.aug-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--tier);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
}

.aug-chip.armed .aug-badge {
  background: #fff;
  color: var(--tier);
}

/* Sealed category cell */
.scorecard .score-cell.aug-sealed {
  background: var(--aug-sealed-bg);
  position: relative;
}

.scorecard .score-cell.aug-sealed::after {
  content: "\1F512";
  font-size: 0.7rem;
  margin-left: 4px;
}

/* All-in confirm spans the sheet's two-column target grid */
.aug-target-list .aug-allin-go { grid-column: 1 / -1; }

/* An armed declaration stays readable even though it can't be pressed again */
button.aug-chip.armed:disabled { opacity: 1; }

/* Category called with Call Shot this turn */
.scorecard .score-cell.aug-called {
  box-shadow: inset 0 0 0 2px var(--aug-tier2);
  position: relative;
}

.scorecard .score-cell.aug-called::after {
  content: "\1F3AF";
  font-size: 0.7rem;
  margin-left: 4px;
}

/* Overlays (pick / reveal / action sheets) */
.aug-overlay .aug-sheet {
  width: min(92vw, 420px);
  max-height: 86vh;
  overflow-y: auto;
  padding: 24px 20px;
  gap: 12px;
}

.aug-title {
  font-size: 1.15rem;
}

.aug-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.aug-tier-badge {
  --tier: var(--aug-tier1);
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--tier);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.aug-tier-badge.tier-2 { --tier: var(--aug-tier2); }
.aug-tier-badge.tier-3 { --tier: var(--aug-tier3); }

.aug-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.aug-card {
  --tier: var(--aug-tier1);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--tier);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
}

.aug-card.tier-2 { --tier: var(--aug-tier2); }
.aug-card.tier-3 { --tier: var(--aug-tier3); }

.aug-card:hover {
  background: color-mix(in srgb, var(--tier) 10%, var(--surface));
}

.aug-card:active {
  transform: scale(0.98);
}

.aug-card-name {
  font-weight: 700;
  font-size: 1rem;
}

.aug-card-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.aug-reveal-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.aug-reveal-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border-left: 4px solid var(--score-mine);
  background: var(--surface-hover);
  text-align: left;
}

.aug-reveal-row.opp {
  border-left-color: var(--score-opponent);
}

.aug-reveal-who {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* Lucky die (game end): one big die per owner, rolled by its owner */
.aug-lottery-row {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin: 6px 0 4px;
}
.aug-lottery-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 96px;
}
/* Same look as a board die, but not .die: Dice.renderAll() repaints every .die on the page. */
.aug-lottery-die {
  width: 72px;
  height: 72px;
  display: grid;
  grid-template-rows: repeat(3, 1fr);
  grid-template-columns: repeat(3, 1fr);
  padding: 8px;
  background: var(--die-bg);
  border: 2px solid var(--die-border);
  border-radius: var(--radius-sm);
}
.aug-lottery-die.rolling { animation: diceShake 0.4s ease infinite; }
.aug-lottery-q {
  grid-row: 1 / 4;
  grid-column: 1 / 4;
  align-self: center;
  justify-self: center;
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text-muted);
}
.aug-lottery-result {
  min-height: 1.3em;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-muted);
}
.aug-lottery-cell.hit .aug-lottery-result { color: var(--success, #2e9d5b); }
.aug-lottery-cell.hit .aug-lottery-die {
  border-color: #e0a93a;
  box-shadow: 0 0 0 3px rgba(224, 169, 58, 0.35), 0 0 16px rgba(224, 169, 58, 0.5);
}
.aug-lottery-cell.miss .aug-lottery-die { opacity: 0.7; }
.aug-lottery-roll { min-width: 160px; }

.aug-choice-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.aug-choice {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--die-border);
  background: var(--die-bg);
  color: var(--pip-color);
  font-family: inherit;
  cursor: pointer;
}

.aug-choice:not(:disabled):hover {
  border-color: var(--accent);
}

.aug-choice:disabled {
  opacity: 0.35;
  cursor: default;
}

.aug-die {
  font-size: 1.4rem;
  font-weight: 700;
}

.aug-target-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 100%;
}

.aug-target {
  padding: 10px 8px;
  min-height: 44px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 0.88rem;
  cursor: pointer;
}

.aug-target:hover {
  border-color: var(--accent);
  background: var(--accent-light);
}

.aug-swap-vals {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.aug-gameover {
  margin-top: 12px;
  font-size: 0.85rem;
  text-align: center;
}

.aug-gameover .aug-note {
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-top: 6px;
}

/* Augment usage announcements: bold, highlighted, longer (see UI.showToast opts.strong) */
.toast.toast-strong {
  font-weight: 700;
  font-size: 0.95rem;
  border-left: 5px solid var(--aug-tier3);
  background: color-mix(in srgb, var(--aug-tier3) 12%, var(--surface));
}

/* Augment pick: countdown, scorecard peek */
.aug-timer {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.aug-timer.low {
  color: var(--danger);
}

.aug-sheet .aug-peek {
  width: 100%;
}

.aug-peek-bar {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  width: min(92vw, 420px);
  z-index: 150;
}

.aug-peek-bar.hidden {
  display: none;
}

.aug-peek-bar .btn-primary {
  box-shadow: var(--shadow-lg);
  font-variant-numeric: tabular-nums;
}


/* ==========================================================================
 * Ascend skin — evolves with augment picks (Lv1 잔불 → Lv2 용암 → Lv3 태양)
 * Level comes from #dice-area[data-ascend-level] (set by DiceSkins: the turn player's level).
 * No attribute / non-augment games = Lv1. Same look in light & dark themes.
 * Cracks (::before) share one shape across levels; ::after = runes / bronze
 * brackets / gold gems. Pips sit above both layers.
 * ========================================================================== */
[data-dice-skin="ascend"] .die,
[data-theme="dark"] [data-dice-skin="ascend"] .die {
  background: radial-gradient(circle at 25% 20%, #57524e 0%, transparent 45%),
    radial-gradient(circle at 80% 85%, rgba(0,0,0,0.3) 0%, transparent 50%),
    repeating-radial-gradient(circle at 37% 61%, transparent 0 3px, rgba(0,0,0,0.06) 3px 4px),
    linear-gradient(145deg, #45413e, #2c2927 60%, #1e1c1a);
  border: 2px solid #1f1c1a;
  overflow: visible;
  isolation: isolate;
  box-shadow: inset 0 2px 0 rgba(255,255,255,0.12), inset 0 -3px 0 rgba(0,0,0,0.3), 0 4px 10px rgba(0,0,0,0.35);
}
[data-dice-skin="ascend"] .die::before,
[data-dice-skin="ascend"] .die::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: center / 100% 100% no-repeat;
}
[data-dice-skin="ascend"] .die::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cdefs%3E%3Cfilter id='g' x='-20%25' y='-20%25' width='140%25' height='140%25'%3E%3CfeGaussianBlur stdDeviation='1.6'/%3E%3C/filter%3E%3C/defs%3E%3Cg fill='none' stroke-linecap='round' stroke-linejoin='round'%3E%3Cg stroke='%23000' stroke-opacity='.6' stroke-width='3.6'%3E%3Cpath d='M0 34 L14 30 L22 38 L31 33'/%3E%3Cpath d='M100 66 L86 70 L80 62 L70 66 L64 78'/%3E%3Cpath d='M58 0 L61 9 L55 16 L60 22'/%3E%3Cpath d='M30 100 L34 90 L28 84'/%3E%3Cpath d='M100 16 L92 21 L95 28'/%3E%3C/g%3E%3Cg stroke='%23a8380a' stroke-width='3.5' opacity='0.9' filter='url%28%23g%29'%3E%3Cpath d='M0 34 L14 30 L22 38 L31 33'/%3E%3Cpath d='M100 66 L86 70 L80 62 L70 66 L64 78'/%3E%3Cpath d='M58 0 L61 9 L55 16 L60 22'/%3E%3Cpath d='M30 100 L34 90 L28 84'/%3E%3Cpath d='M100 16 L92 21 L95 28'/%3E%3C/g%3E%3Cg stroke='%23c9561c' stroke-width='1.6'%3E%3Cpath d='M0 34 L14 30 L22 38 L31 33'/%3E%3Cpath d='M100 66 L86 70 L80 62 L70 66 L64 78'/%3E%3Cpath d='M58 0 L61 9 L55 16 L60 22'/%3E%3Cpath d='M30 100 L34 90 L28 84'/%3E%3Cpath d='M100 16 L92 21 L95 28'/%3E%3C/g%3E%3Cg stroke='%23f08a4a' stroke-width='0.6'%3E%3Cpath d='M0 34 L14 30 L22 38 L31 33'/%3E%3Cpath d='M100 66 L86 70 L80 62 L70 66 L64 78'/%3E%3Cpath d='M58 0 L61 9 L55 16 L60 22'/%3E%3Cpath d='M30 100 L34 90 L28 84'/%3E%3Cpath d='M100 16 L92 21 L95 28'/%3E%3C/g%3E%3C/g%3E%3Cg fill='none' stroke='%23000' stroke-opacity='.45' stroke-width='1.6'%3E%3Cpath d='M7 5 v7 M4.5 8.5 h5'/%3E%3Cpath d='M89 6 l3.5 3 l-3.5 3 M87 6 v7'/%3E%3Cpath d='M6 92 l3.5 -5 l3.5 5'/%3E%3Cpath d='M88 90 h7 M91.5 86.5 v7'/%3E%3C/g%3E%3C/svg%3E");
  animation: ascendEmber 2.8s ease-in-out infinite;
}
[data-dice-skin="ascend"] .die::after { background-image: none; }
[data-dice-skin="ascend"] .pip,
[data-theme="dark"] [data-dice-skin="ascend"] .pip {
  position: relative;
  z-index: 1;
  width: 74%;
  height: auto;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, #fff8e6 0 26%, #ffd27a 42%, #ff8c2a 62%, #4a1c08 76%, #140d0a 100%);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.7), 0 0 8px rgba(255,150,50,0.75);
}
@keyframes ascendEmber { 50% { opacity: 0.72; } }
/* Dark mode Lv1: the basalt body is ~1.3:1 against the dark page, so add a thin ember rim (>=3:1). */
[data-theme="dark"] [data-dice-skin="ascend"]:not([data-dice-color="claude"]):not([data-ascend-level="2"]):not([data-ascend-level="3"]) .die {
  box-shadow: inset 0 2px 0 rgba(255,255,255,0.12), inset 0 -3px 0 rgba(0,0,0,0.3), 0 0 0 1px #9a5e2c, 0 4px 10px rgba(0,0,0,0.35);
}

/* Lv2 — 용암: 균열이 타오르고 청동 모서리가 묶음 */
[data-dice-skin="ascend"][data-ascend-level="2"] .die,
[data-theme="dark"] [data-dice-skin="ascend"][data-ascend-level="2"] .die {
  background: radial-gradient(circle at 50% 50%, rgba(255,106,26,0.16) 0%, transparent 62%),
    radial-gradient(circle at 25% 20%, #5e4f45 0%, transparent 45%),
    repeating-radial-gradient(circle at 37% 61%, transparent 0 3px, rgba(0,0,0,0.06) 3px 4px),
    linear-gradient(145deg, #463a33, #2a221d 60%, #1b1512);
  border-color: #5c3515;
  box-shadow: inset 0 0 14px rgba(255,138,26,0.3), 0 0 12px rgba(255,138,26,0.45), 0 4px 10px rgba(0,0,0,0.4);
}
[data-dice-skin="ascend"][data-ascend-level="2"] .die::before { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cdefs%3E%3Cfilter id='g' x='-20%25' y='-20%25' width='140%25' height='140%25'%3E%3CfeGaussianBlur stdDeviation='1.6'/%3E%3C/filter%3E%3C/defs%3E%3Cg fill='none' stroke-linecap='round' stroke-linejoin='round'%3E%3Cg stroke='%23000' stroke-opacity='.6' stroke-width='3.5'%3E%3Cpath d='M0 34 L14 30 L22 38 L31 33'/%3E%3Cpath d='M100 66 L86 70 L80 62 L70 66 L64 78'/%3E%3Cpath d='M58 0 L61 9 L55 16 L60 22'/%3E%3Cpath d='M30 100 L34 90 L28 84'/%3E%3Cpath d='M100 16 L92 21 L95 28'/%3E%3C/g%3E%3Cg stroke='%23ff7a1a' stroke-width='3.5' opacity='0.75' filter='url%28%23g%29'%3E%3Cpath d='M0 34 L14 30 L22 38 L31 33'/%3E%3Cpath d='M100 66 L86 70 L80 62 L70 66 L64 78'/%3E%3Cpath d='M58 0 L61 9 L55 16 L60 22'/%3E%3Cpath d='M30 100 L34 90 L28 84'/%3E%3Cpath d='M100 16 L92 21 L95 28'/%3E%3C/g%3E%3Cg stroke='%23ffb347' stroke-width='1.5'%3E%3Cpath d='M0 34 L14 30 L22 38 L31 33'/%3E%3Cpath d='M100 66 L86 70 L80 62 L70 66 L64 78'/%3E%3Cpath d='M58 0 L61 9 L55 16 L60 22'/%3E%3Cpath d='M30 100 L34 90 L28 84'/%3E%3Cpath d='M100 16 L92 21 L95 28'/%3E%3C/g%3E%3Cg stroke='%23fff0d6' stroke-width='0.57'%3E%3Cpath d='M0 34 L14 30 L22 38 L31 33'/%3E%3Cpath d='M100 66 L86 70 L80 62 L70 66 L64 78'/%3E%3Cpath d='M58 0 L61 9 L55 16 L60 22'/%3E%3Cpath d='M30 100 L34 90 L28 84'/%3E%3Cpath d='M100 16 L92 21 L95 28'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E"); animation: none; }
[data-dice-skin="ascend"][data-ascend-level="2"] .die::after { inset: -2px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cdefs%3E%3ClinearGradient id='m' x1='0' y1='0' x2='1' y2='1'%3E%3Cstop offset='0' stop-color='%23f0bd7c'/%3E%3Cstop offset='.45' stop-color='%23a8692f'/%3E%3Cstop offset='.7' stop-color='%235c3515'/%3E%3Cstop offset='1' stop-color='%23f0bd7c'/%3E%3C/linearGradient%3E%3C/defs%3E%3Cg fill='none' stroke-linejoin='round'%3E%3Cg stroke='%231d1007' stroke-width='6'%3E%3Cpath d='M4 24 V4 H24'/%3E%3Cpath d='M76 4 H96 V24'/%3E%3Cpath d='M96 76 V96 H76'/%3E%3Cpath d='M24 96 H4 V76'/%3E%3C/g%3E%3Cg stroke='url%28%23m%29' stroke-width='3.6'%3E%3Cpath d='M4 24 V4 H24'/%3E%3Cpath d='M76 4 H96 V24'/%3E%3Cpath d='M96 76 V96 H76'/%3E%3Cpath d='M24 96 H4 V76'/%3E%3C/g%3E%3C/g%3E%3Cg fill='%23f6cf98' stroke='%235c3515' stroke-width='.7'%3E%3Ccircle cx='10' cy='10' r='2.4'/%3E%3Ccircle cx='90' cy='10' r='2.4'/%3E%3Ccircle cx='90' cy='90' r='2.4'/%3E%3Ccircle cx='10' cy='90' r='2.4'/%3E%3C/g%3E%3C/svg%3E"); }
[data-dice-skin="ascend"][data-ascend-level="2"] .pip,
[data-theme="dark"] [data-dice-skin="ascend"][data-ascend-level="2"] .pip {
  width: 80%;
  background: radial-gradient(circle, #fff 0 30%, #ffd9a0 42%, #ff8a1a 54%, #0b0b14 58% 62%, #f0bd7c 66%, #a8692f 82%, #5c3515 100%);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.8), 0 0 8px #ff8a1a, 0 2px 3px rgba(0,0,0,0.8);
}

/* Lv3 — 태양: 흑요석 속 황금빛 균열 + 황금 테두리 + 루비 */
[data-dice-skin="ascend"][data-ascend-level="3"] .die,
[data-theme="dark"] [data-dice-skin="ascend"][data-ascend-level="3"] .die {
  background: radial-gradient(1px 1px at 18% 70%, rgba(255,217,160,0.7) 50%, transparent 51%),
    radial-gradient(1px 1px at 82% 28%, rgba(255,217,160,0.7) 50%, transparent 51%),
    radial-gradient(ellipse 70% 55% at 50% 50%, rgba(122,30,8,0.45), transparent 70%),
    radial-gradient(circle at 50% 50%, #2e0d06, #140503 70%, #070101);
  border-color: #fff0c0;
  box-shadow: 0 0 0 2px #e0a93a, 0 0 0 3.5px #6a4508, 0 0 12px rgba(224,169,58,0.6), 0 0 22px rgba(255,122,26,0.55), inset 0 0 14px rgba(255,122,26,0.35);
}
[data-dice-skin="ascend"][data-ascend-level="3"]:not(.ascend-up) .die:not(.rolling) { animation: ascendSun 2.6s ease-in-out infinite; }
[data-dice-skin="ascend"][data-ascend-level="3"] .die::before { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cdefs%3E%3Cfilter id='g' x='-20%25' y='-20%25' width='140%25' height='140%25'%3E%3CfeGaussianBlur stdDeviation='1.6'/%3E%3C/filter%3E%3C/defs%3E%3Cg fill='none' stroke-linecap='round' stroke-linejoin='round'%3E%3Cg stroke='%23ffb020' stroke-width='3.7' opacity='1' filter='url%28%23g%29'%3E%3Cpath d='M0 34 L14 30 L22 38 L31 33'/%3E%3Cpath d='M100 66 L86 70 L80 62 L70 66 L64 78'/%3E%3Cpath d='M58 0 L61 9 L55 16 L60 22'/%3E%3Cpath d='M30 100 L34 90 L28 84'/%3E%3Cpath d='M100 16 L92 21 L95 28'/%3E%3C/g%3E%3Cg stroke='%23ffe7a0' stroke-width='1.7'%3E%3Cpath d='M0 34 L14 30 L22 38 L31 33'/%3E%3Cpath d='M100 66 L86 70 L80 62 L70 66 L64 78'/%3E%3Cpath d='M58 0 L61 9 L55 16 L60 22'/%3E%3Cpath d='M30 100 L34 90 L28 84'/%3E%3Cpath d='M100 16 L92 21 L95 28'/%3E%3C/g%3E%3Cg stroke='%23ffffff' stroke-width='0.65'%3E%3Cpath d='M0 34 L14 30 L22 38 L31 33'/%3E%3Cpath d='M100 66 L86 70 L80 62 L70 66 L64 78'/%3E%3Cpath d='M58 0 L61 9 L55 16 L60 22'/%3E%3Cpath d='M30 100 L34 90 L28 84'/%3E%3Cpath d='M100 16 L92 21 L95 28'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E"); animation: none; }
[data-dice-skin="ascend"][data-ascend-level="3"] .die::after { inset: -4px; border-radius: 0; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Crect x='7' y='7' width='86' height='86' rx='8' fill='none' stroke='%23ffe08a' stroke-opacity='.55' stroke-width='1'/%3E%3Cpath d='M50 -2 L55 3 L50 8 L45 3 Z' fill='%23ff5a3a' stroke='%23fff3c4' stroke-width='1.1'/%3E%3Cpath d='M50 -2 L55 3 L50 3 Z' fill='%23ffd0b8'/%3E%3Cpath d='M50 92 L55 97 L50 102 L45 97 Z' fill='%23ff5a3a' stroke='%23fff3c4' stroke-width='1.1'/%3E%3Cpath d='M50 92 L55 97 L50 97 Z' fill='%23ffd0b8'/%3E%3C/svg%3E"); }
[data-dice-skin="ascend"][data-ascend-level="3"] .pip,
[data-theme="dark"] [data-dice-skin="ascend"][data-ascend-level="3"] .pip {
  width: 86%;
  background: radial-gradient(circle, #fff 0 38%, #fff3c4 50%, #ffbf3d 64%, #6a4508 72%, transparent 74%);
  box-shadow: 0 0 5px rgba(255,255,255,0.4), 0 0 10px #ffbf3d, 0 0 18px #ff7a1a;
}
@keyframes ascendSun {
  50% { box-shadow: 0 0 0 2px #e0a93a, 0 0 0 3.5px #6a4508, 0 0 16px rgba(224,169,58,0.8), 0 0 30px rgba(255,122,26,0.7), inset 0 0 14px rgba(255,122,26,0.45); }
}

/* Mobile: dice sit 6px apart, so keep Lv3's outer gold rings within 2.5px per side. */
@media (max-width: 480px) {
  [data-dice-skin="ascend"][data-ascend-level="3"] .die,
  [data-theme="dark"] [data-dice-skin="ascend"][data-ascend-level="3"] .die {
    box-shadow: 0 0 0 1.5px #e0a93a, 0 0 0 2.5px #6a4508, 0 0 10px rgba(224,169,58,0.55), 0 0 18px rgba(255,122,26,0.5), inset 0 0 12px rgba(255,122,26,0.35);
  }
  [data-dice-skin="ascend"][data-ascend-level="3"]:not(.ascend-up) .die:not(.rolling) { animation-name: ascendSunSm; }
}
@keyframes ascendSunSm {
  50% { box-shadow: 0 0 0 1.5px #e0a93a, 0 0 0 2.5px #6a4508, 0 0 14px rgba(224,169,58,0.75), 0 0 24px rgba(255,122,26,0.65), inset 0 0 12px rgba(255,122,26,0.45); }
}

/* Level-up burst (DiceSkins.ascendRollStopped adds .ascend-up for ~1.4s) */
[data-dice-skin="ascend"].ascend-up .die { animation: ascendUp 0.9s cubic-bezier(0.3, 1.4, 0.5, 1) both; }
[data-dice-skin="ascend"].ascend-up .die:nth-child(2) { animation-delay: 0.08s; }
[data-dice-skin="ascend"].ascend-up .die:nth-child(3) { animation-delay: 0.16s; }
[data-dice-skin="ascend"].ascend-up .die:nth-child(4) { animation-delay: 0.24s; }
[data-dice-skin="ascend"].ascend-up .die:nth-child(5) { animation-delay: 0.32s; }
@keyframes ascendUp {
  0% { transform: scale(1) rotate(0); }
  35% { transform: scale(0.6) rotate(-90deg); filter: brightness(3) hue-rotate(var(--ascend-hue, 0deg)); }
  100% { transform: scale(1) rotate(0); filter: hue-rotate(var(--ascend-hue, 0deg)); }
}

/* Reduced motion: no endless ember/sun loops, and the level-up becomes a soft fade instead of a spin + flash. */
@media (prefers-reduced-motion: reduce) {
  [data-dice-skin="ascend"] .die::before { animation: none; }
  [data-dice-skin="ascend"][data-ascend-level="3"]:not(.ascend-up) .die:not(.rolling) { animation: none; }
  [data-dice-skin="ascend"].ascend-up .die { animation: ascendUpCalm 0.6s ease-out both; }
}
@keyframes ascendUpCalm { 0% { opacity: 0.35; } 100% { opacity: 1; } }

/* Preview (skin selector + header cube) shows the final Lv3 form */
.skin-preview-die[data-dice-skin="ascend"],
[data-theme="dark"] .skin-preview-die[data-dice-skin="ascend"] {
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cdefs%3E%3Cfilter id='g' x='-20%25' y='-20%25' width='140%25' height='140%25'%3E%3CfeGaussianBlur stdDeviation='1.6'/%3E%3C/filter%3E%3C/defs%3E%3Cg fill='none' stroke-linecap='round' stroke-linejoin='round'%3E%3Cg stroke='%23ffb020' stroke-width='3.7' opacity='1' filter='url%28%23g%29'%3E%3Cpath d='M0 34 L14 30 L22 38 L31 33'/%3E%3Cpath d='M100 66 L86 70 L80 62 L70 66 L64 78'/%3E%3Cpath d='M58 0 L61 9 L55 16 L60 22'/%3E%3Cpath d='M30 100 L34 90 L28 84'/%3E%3Cpath d='M100 16 L92 21 L95 28'/%3E%3C/g%3E%3Cg stroke='%23ffe7a0' stroke-width='1.7'%3E%3Cpath d='M0 34 L14 30 L22 38 L31 33'/%3E%3Cpath d='M100 66 L86 70 L80 62 L70 66 L64 78'/%3E%3Cpath d='M58 0 L61 9 L55 16 L60 22'/%3E%3Cpath d='M30 100 L34 90 L28 84'/%3E%3Cpath d='M100 16 L92 21 L95 28'/%3E%3C/g%3E%3Cg stroke='%23ffffff' stroke-width='0.65'%3E%3Cpath d='M0 34 L14 30 L22 38 L31 33'/%3E%3Cpath d='M100 66 L86 70 L80 62 L70 66 L64 78'/%3E%3Cpath d='M58 0 L61 9 L55 16 L60 22'/%3E%3Cpath d='M30 100 L34 90 L28 84'/%3E%3Cpath d='M100 16 L92 21 L95 28'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E") center / 100% 100% no-repeat,
    radial-gradient(ellipse 70% 55% at 50% 50%, rgba(122,30,8,0.45), transparent 70%),
    radial-gradient(circle at 50% 50%, #2e0d06, #140503 70%, #070101);
  border-color: #e0a93a;
  box-shadow: 0 0 6px rgba(255,122,26,0.5);
}
.skin-preview-die[data-dice-skin="ascend"] .mini-pip,
[data-theme="dark"] .skin-preview-die[data-dice-skin="ascend"] .mini-pip {
  background: radial-gradient(circle, #fff 0 38%, #fff3c4 50%, #ffbf3d 70%, #b8860b 100%);
  box-shadow: 0 0 3px #ffbf3d;
}
.skin-option.active[data-skin-id="ascend"],
[data-theme="dark"] .skin-option.active[data-skin-id="ascend"] { border-color: #e0a93a; }

/* ─── Ascend colors (DiceSkins token 'ascend.<color>', set as data-dice-color) ───
 * blue / red / violet / green hue-rotate the whole gold die (body, cracks, glow, pips).
 * The held badge counter-rotates so it stays the app accent blue. */
[data-dice-color="blue"]   { --ascend-hue: 180deg; }
[data-dice-color="red"]    { --ascend-hue: -40deg; }
[data-dice-color="violet"] { --ascend-hue: -110deg; }
[data-dice-color="green"]  { --ascend-hue: 85deg; }
[data-dice-skin="ascend"][data-dice-color] .die,
.skin-preview-die[data-dice-skin="ascend"][data-dice-color] { filter: hue-rotate(var(--ascend-hue, 0deg)); }
[data-dice-skin="ascend"][data-dice-color] .die .held-check { filter: hue-rotate(calc(-1 * var(--ascend-hue, 0deg))); }

/* Claude Ascend (room bot's dice; unlock = beat it 5 times): ivory clay → peach → terracotta,
 * terracotta / ivory spark pips. Cracks are hidden; Lv2 brackets and Lv3 gems stay. */
[data-dice-skin="ascend"][data-dice-color="claude"] .die,
[data-theme="dark"] [data-dice-skin="ascend"][data-dice-color="claude"] .die {
  background: radial-gradient(circle at 28% 22%, #fffdf8 0%, transparent 50%),
    linear-gradient(145deg, #f4efe6, #e9e1d3 60%, #ddd1be);
  border: 2px solid #c96442;
  box-shadow: inset 0 2px 0 rgba(255,255,255,0.7), inset 0 -3px 0 rgba(120,70,40,0.15), 0 4px 10px rgba(0,0,0,0.22);
}
[data-dice-skin="ascend"][data-dice-color="claude"] .die::before { display: none; }
/* Spark pips are 112% of a cell; minmax(0,1fr) keeps the rows from growing (otherwise pips sit ~2-3px low). */
[data-dice-skin="ascend"][data-dice-color="claude"] .die,
.skin-preview-die[data-dice-skin="ascend"][data-dice-color="claude"] {
  grid-template-rows: repeat(3, minmax(0, 1fr));
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
[data-dice-skin="ascend"][data-dice-color="claude"] .pip,
[data-theme="dark"] [data-dice-skin="ascend"][data-dice-color="claude"] .pip,
.skin-preview-die[data-dice-skin="ascend"][data-dice-color="claude"] .mini-pip,
[data-theme="dark"] .skin-preview-die[data-dice-skin="ascend"][data-dice-color="claude"] .mini-pip {
  width: 112%;
  height: auto;
  aspect-ratio: 1;
  justify-self: center;
  align-self: center;
  border-radius: 0;
  background: #d97757;
  box-shadow: none;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cg fill='black'%3E%3Cellipse cx='50' cy='27' rx='10' ry='25' transform='rotate(0 50 50)'/%3E%3Cellipse cx='50' cy='33' rx='8' ry='19' transform='rotate(45 50 50)'/%3E%3Cellipse cx='50' cy='27' rx='10' ry='25' transform='rotate(90 50 50)'/%3E%3Cellipse cx='50' cy='33' rx='8' ry='19' transform='rotate(135 50 50)'/%3E%3Cellipse cx='50' cy='27' rx='10' ry='25' transform='rotate(180 50 50)'/%3E%3Cellipse cx='50' cy='33' rx='8' ry='19' transform='rotate(225 50 50)'/%3E%3Cellipse cx='50' cy='27' rx='10' ry='25' transform='rotate(270 50 50)'/%3E%3Cellipse cx='50' cy='33' rx='8' ry='19' transform='rotate(315 50 50)'/%3E%3Ccircle cx='50' cy='50' r='14'/%3E%3C/g%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cg fill='black'%3E%3Cellipse cx='50' cy='27' rx='10' ry='25' transform='rotate(0 50 50)'/%3E%3Cellipse cx='50' cy='33' rx='8' ry='19' transform='rotate(45 50 50)'/%3E%3Cellipse cx='50' cy='27' rx='10' ry='25' transform='rotate(90 50 50)'/%3E%3Cellipse cx='50' cy='33' rx='8' ry='19' transform='rotate(135 50 50)'/%3E%3Cellipse cx='50' cy='27' rx='10' ry='25' transform='rotate(180 50 50)'/%3E%3Cellipse cx='50' cy='33' rx='8' ry='19' transform='rotate(225 50 50)'/%3E%3Cellipse cx='50' cy='27' rx='10' ry='25' transform='rotate(270 50 50)'/%3E%3Cellipse cx='50' cy='33' rx='8' ry='19' transform='rotate(315 50 50)'/%3E%3Ccircle cx='50' cy='50' r='14'/%3E%3C/g%3E%3C/svg%3E") center / contain no-repeat;
}
[data-dice-skin="ascend"][data-dice-color="claude"] .pip.hidden,
.skin-preview-die[data-dice-skin="ascend"][data-dice-color="claude"] .mini-pip.hidden { visibility: hidden; }
[data-dice-skin="ascend"][data-dice-color="claude"][data-ascend-level="2"] .die,
[data-theme="dark"] [data-dice-skin="ascend"][data-dice-color="claude"][data-ascend-level="2"] .die {
  background: radial-gradient(circle at 28% 22%, #fff6ee 0%, transparent 50%),
    linear-gradient(145deg, #f7e4d6, #efcdb6 60%, #e3b597);
  border-color: #b85a3c;
  box-shadow: inset 0 0 12px rgba(217,119,87,0.25), 0 0 12px rgba(217,119,87,0.5), 0 4px 10px rgba(0,0,0,0.25);
}
[data-dice-skin="ascend"][data-dice-color="claude"][data-ascend-level="2"] .pip,
[data-theme="dark"] [data-dice-skin="ascend"][data-dice-color="claude"][data-ascend-level="2"] .pip { background: #c15f3c; }
[data-dice-skin="ascend"][data-dice-color="claude"][data-ascend-level="3"] .die,
[data-theme="dark"] [data-dice-skin="ascend"][data-dice-color="claude"][data-ascend-level="3"] .die,
.skin-preview-die[data-dice-skin="ascend"][data-dice-color="claude"],
[data-theme="dark"] .skin-preview-die[data-dice-skin="ascend"][data-dice-color="claude"] {
  background: radial-gradient(circle at 30% 24%, #ec9a78 0%, transparent 55%),
    linear-gradient(145deg, #d97757, #c4613f 60%, #a84e2e);
  border-color: #fbf3ea;
  box-shadow: 0 0 0 2px #f4e6d6, 0 0 0 3.5px #7a3520, 0 0 12px rgba(217,119,87,0.65), 0 0 22px rgba(217,119,87,0.45);
}
.skin-preview-die[data-dice-skin="ascend"][data-dice-color="claude"] { box-shadow: 0 0 6px rgba(217,119,87,0.55); }
[data-dice-skin="ascend"][data-dice-color="claude"][data-ascend-level="3"] .pip,
[data-theme="dark"] [data-dice-skin="ascend"][data-dice-color="claude"][data-ascend-level="3"] .pip,
.skin-preview-die[data-dice-skin="ascend"][data-dice-color="claude"] .mini-pip,
[data-theme="dark"] .skin-preview-die[data-dice-skin="ascend"][data-dice-color="claude"] .mini-pip { background: #fdf6ec; }
[data-dice-skin="ascend"][data-dice-color="claude"][data-ascend-level="3"]:not(.ascend-up) .die:not(.rolling) { animation: ascendClaude 2.6s ease-in-out infinite; }
@keyframes ascendClaude {
  50% { box-shadow: 0 0 0 2px #f4e6d6, 0 0 0 3.5px #7a3520, 0 0 16px rgba(217,119,87,0.85), 0 0 30px rgba(217,119,87,0.6); }
}
@media (max-width: 480px) {
  [data-dice-skin="ascend"][data-dice-color="claude"][data-ascend-level="3"] .die,
  [data-theme="dark"] [data-dice-skin="ascend"][data-dice-color="claude"][data-ascend-level="3"] .die {
    box-shadow: 0 0 0 1.5px #f4e6d6, 0 0 0 2.5px #7a3520, 0 0 10px rgba(217,119,87,0.6), 0 0 18px rgba(217,119,87,0.4);
  }
  [data-dice-skin="ascend"][data-dice-color="claude"][data-ascend-level="3"]:not(.ascend-up) .die:not(.rolling) { animation: none; }
}
@media (prefers-reduced-motion: reduce) {
  [data-dice-skin="ascend"][data-dice-color="claude"][data-ascend-level="3"]:not(.ascend-up) .die:not(.rolling) { animation: none; }
}
.skin-option.active[data-skin-id="ascend"] .skin-preview-die[data-dice-color="claude"] { border-color: #fbf3ea; }

/* ===== Secret game room (js/minigames.js) ===== */
.lab-desc { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 16px; }
.lab-games { display: flex; flex-direction: column; gap: 10px; }
.lab-game {
  display: flex; align-items: center; gap: 14px; width: 100%;
  padding: 14px; text-align: left; cursor: pointer;
  background: var(--surface); color: var(--text);
  border: 1.5px solid var(--border); border-radius: var(--radius);
  transition: border-color var(--transition), background var(--transition);
}
.lab-game:hover { border-color: var(--accent); background: var(--surface-hover); }
.lab-game-icon { width: 52px; height: 52px; flex: none; }
.lab-game-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.lab-game-title { font-weight: 700; font-size: 1.05rem; }
.lab-game-desc { font-size: 0.85rem; color: var(--text-muted); }
.lab-game-best { font-size: 0.78rem; color: var(--text-muted); }
.lab-game-best:empty { display: none; }

/* Fence board colours follow the design mockup in both themes. */
:root { --fence-board: #646488; --fence-board-edge: #7b7ba3; --fence-gold: #d8b86c; --fence-answer: #5fd38a; }

.fence-top { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.fence-top h2 { flex: 1; font-size: 1.35rem; margin: 0; }
.fence-top .btn-tutorial { margin: 0; }
.fence-back {
  width: 36px; height: 36px; border-radius: 50%; flex: none;
  border: 1.5px solid var(--border); background: none; color: var(--text);
  font-size: 1.5rem; line-height: 1; cursor: pointer; padding: 0 0 3px;
}
.fence-back:hover { border-color: var(--accent); color: var(--accent); }

.fence-levels { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 10px; }
.fence-levels button {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 7px 4px; border-radius: var(--radius-sm); cursor: pointer;
  border: 1.5px solid var(--border); background: var(--surface); color: var(--text);
  font-size: 0.85rem; font-weight: 600;
}
.fence-levels button small { font-size: 0.7rem; font-weight: 400; color: var(--text-muted); }
.fence-levels button.active { border-color: var(--accent); background: var(--accent-light); color: var(--accent); }

.fence-status { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.fence-timer { font-size: 1.3rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.fence-best { font-size: 0.85rem; color: var(--text-muted); }

.fence-board {
  background: var(--fence-board); border: 1.5px solid var(--fence-board-edge);
  border-radius: 16px; padding: 6px; aspect-ratio: 1 / 1;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 18px rgba(30, 30, 60, 0.25);
}
.fence-svg { width: 100%; height: 100%; display: block; touch-action: none; user-select: none; -webkit-user-select: none; cursor: pointer; }
.fence-dots circle { fill: var(--fence-gold); }
.fence-nums text { fill: #fff; font-size: 44px; font-weight: 500; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; pointer-events: none; }
.fence-lines line { stroke: var(--fence-gold); stroke-width: 12; stroke-linecap: round; }
.fence-marks path { stroke: rgba(255, 255, 255, 0.55); stroke-width: 4; stroke-linecap: round; fill: none; }
.fence-answer line { stroke: var(--fence-answer); stroke-width: 22; stroke-linecap: round; opacity: 0.55; }
.fence-board.is-over .fence-svg { cursor: default; }
.fence-board.is-win { border-color: var(--fence-gold); box-shadow: 0 0 0 3px rgba(216, 184, 108, 0.45), 0 6px 18px rgba(30, 30, 60, 0.25); }
.fence-making { color: rgba(255, 255, 255, 0.8); font-size: 0.95rem; }

.fence-tools { display: flex; align-items: center; gap: 6px; margin-top: 12px; }
.fence-mode { display: flex; border: 1.5px solid var(--border); border-radius: 20px; overflow: hidden; margin-right: auto; }
.fence-mode button {
  border: none; background: none; color: var(--text-muted); cursor: pointer;
  padding: 7px 14px; font-size: 0.85rem; font-weight: 600;
}
.fence-mode button.active { background: var(--accent); color: #fff; }
.fence-tool {
  border: 1.5px solid var(--border); background: none; color: var(--text);
  border-radius: 20px; padding: 7px 12px; font-size: 0.85rem; cursor: pointer;
}
.fence-tool:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.fence-tool.armed { border-color: var(--danger); color: var(--danger); }
.fence-tools button:disabled, .fence-mode button:disabled { opacity: 0.45; cursor: not-allowed; }

.fence-buzzer {
  display: block; width: 100%; margin-top: 14px; min-height: 56px;
  border: none; border-radius: 28px; cursor: pointer;
  background: linear-gradient(180deg, #e8c879, #c99f45); color: #3a2a08;
  font-size: 1.15rem; font-weight: 800; letter-spacing: 0.04em;
  box-shadow: 0 4px 0 #9c7a2e, 0 6px 14px rgba(160, 120, 40, 0.3);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.fence-buzzer:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 #9c7a2e, 0 3px 8px rgba(160, 120, 40, 0.3); }
.fence-buzzer.armed { background: linear-gradient(180deg, #f07b6b, #d24c3c); color: #fff; box-shadow: 0 4px 0 #9a2f23, 0 6px 14px rgba(200, 60, 40, 0.3); animation: fenceArmed 0.8s ease infinite alternate; }
.fence-buzzer:disabled { opacity: 0.5; cursor: not-allowed; }
.fence-buzzer[hidden] { display: none; }
@keyframes fenceArmed { from { filter: brightness(1); } to { filter: brightness(1.15); } }

.fence-result { margin-top: 14px; text-align: center; display: flex; flex-direction: column; gap: 8px; }
.fence-result[hidden] { display: none; }
.fence-result-title { font-size: 1.2rem; font-weight: 700; }
.fence-result-detail { color: var(--text-muted); font-size: 0.92rem; }

/* Rules overlay, styled after the mockup */
.overlay-content.fence-rules {
  position: relative; width: min(440px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow-y: auto;
  background: #35373c; color: #f1f1f4; padding: 28px 22px 22px; gap: 12px;
}
.fence-rules h3 { font-size: 1.8rem; font-weight: 800; margin: 0; }
.fence-rules-badge {
  display: inline-block; padding: 4px 14px; border-radius: 6px;
  border: 1.5px solid #8a86c8; background: #3c3a5a; color: #c9c6ee;
  font-size: 0.78rem; font-weight: 700; letter-spacing: 0.25em;
}
.fence-rules-close {
  position: absolute; top: 14px; right: 14px; width: 36px; height: 36px;
  border: none; background: none; color: #c4c4cc; font-size: 1.9rem; line-height: 1; cursor: pointer;
}
.fence-rules-close:hover { color: #fff; }
.fence-board-example { width: 100%; max-width: 320px; aspect-ratio: auto; }
.fence-board-example .fence-svg { cursor: default; }
.fence-rules-list { text-align: left; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; font-size: 0.9rem; line-height: 1.5; }
.fence-rules-controls { font-size: 0.82rem; color: #b8b8c4; text-align: left; line-height: 1.5; border-top: 1px solid #4a4c52; padding-top: 10px; width: 100%; }

@media (max-width: 480px) {
  .lab-card { padding: 20px 16px; }
  .fence-mode button { padding: 7px 11px; }
  .fence-tool { padding: 7px 10px; }
}
