#game-root {
  --g9-panel: linear-gradient(180deg, #33261a 0%, #21170f 100%);
  --g9-edge: #5a4128;
  --g9-gold: #f0b95a;
  --g9-text: #f6ead4;
  --g9-dim: #b79c76;
}

#game-root .g9-shell {
  max-width: 780px;
  margin: 0 auto;
  padding: 10px;
  border-radius: 16px;
  background: radial-gradient(120% 80% at 50% 0%, #3d2c1c 0%, #1c130b 100%);
  box-shadow: 0 20px 44px rgba(20, 10, 2, 0.35), 0 0 0 1px #4a3620 inset;
  color: var(--g9-text);
  font-family: Inter, Arial, sans-serif;
}

.cg-shell-game .cg-stage-main #game-root > .g9-shell {
  max-width: min(100%, 780px) !important;
}

#game-root .g9-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: nowrap;
}

#game-root .g9-stats {
  display: flex;
  align-items: stretch;
  gap: 6px;
  min-width: 0;
}

#game-root .g9-stat {
  min-width: 0;
  padding: 5px 10px;
  border: 1px solid var(--g9-edge);
  border-radius: 9px;
  background: var(--g9-panel);
}

#game-root .g9-stat span {
  display: block;
  color: var(--g9-dim);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  line-height: 1.1;
  text-transform: uppercase;
}

#game-root .g9-stat strong {
  display: block;
  margin-top: 2px;
  color: var(--g9-gold);
  font-size: 17px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  white-space: nowrap;
}

#game-root .g9-icons {
  display: flex;
  align-items: center;
  gap: 6px;
}

#game-root .g9-icon,
#game-root .g9-btn,
#game-root .g9-seg {
  display: inline-grid;
  place-items: center;
  min-height: 44px;
  min-width: 44px;
  border: 1px solid var(--g9-edge);
  border-radius: 10px;
  background: var(--g9-panel);
  color: var(--g9-text);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

#game-root .g9-icon {
  padding: 0;
}

#game-root .g9-icon svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#game-root .g9-icon:hover,
#game-root .g9-btn:hover,
#game-root .g9-seg:hover {
  transform: translateY(-1px);
  border-color: var(--g9-gold);
}

#game-root .g9-icon:focus-visible,
#game-root .g9-btn:focus-visible,
#game-root .g9-seg:focus-visible,
#game-root .g9-canvas:focus-visible {
  outline: 3px solid rgba(240, 185, 90, 0.6);
  outline-offset: 2px;
}

#game-root .g9-btn:disabled,
#game-root .g9-seg:disabled {
  opacity: 0.4;
  cursor: default;
  transform: none;
}

#game-root .g9-btn-primary,
#game-root .g9-seg-on {
  border-color: transparent;
  background: linear-gradient(180deg, #f6c66e, #d9973a);
  color: #2a1a08;
}

#game-root .g9-seg-on:hover,
#game-root .g9-btn-primary:hover {
  border-color: transparent;
}

#game-root .g9-status {
  margin: 8px 0;
  color: var(--g9-text);
  font-size: 14px;
  font-weight: 700;
  text-align: center;
}

#game-root .g9-board {
  position: relative;
  width: min(100%, calc(100vh - 340px), 700px);
  min-width: 260px;
  margin: 0 auto;
  border: 3px solid #2a1a0a;
  border-radius: 10px;
  background: #dcae6c;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.5), 0 0 0 1px #7a5426;
  overflow: hidden;
}

#game-root .g9-canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  touch-action: manipulation;
  cursor: pointer;
}

#game-root .g9-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 12px;
  background: rgba(20, 12, 4, 0.55);
  backdrop-filter: blur(2px);
  animation: g9-fade 180ms ease;
}

#game-root .g9-overlay[hidden] {
  display: none;
}

#game-root .g9-overlay-full {
  position: fixed;
  z-index: 80;
  overflow: auto;
  background: rgba(14, 8, 2, 0.75);
}

@keyframes g9-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes g9-pop {
  from { opacity: 0; transform: scale(0.92) translateY(8px); }
  to { opacity: 1; transform: none; }
}

#game-root .g9-card {
  width: min(100%, 340px);
  padding: 16px 18px 18px;
  border: 1px solid var(--g9-edge);
  border-radius: 14px;
  background: var(--g9-panel);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.5);
  animation: g9-pop 220ms ease;
}

#game-root .g9-overlay-full .g9-card {
  width: min(100%, 560px);
  max-height: 86vh;
  overflow: auto;
  text-align: left;
}

#game-root .g9-card h2 {
  margin: 0 0 6px;
  color: var(--g9-gold);
  font-size: 22px;
  line-height: 1.15;
}

#game-root .g9-card p {
  margin: 0 0 8px;
  color: var(--g9-text);
  font-size: 14px;
  line-height: 1.5;
}

#game-root .g9-card p:last-child {
  margin-bottom: 0;
}

#game-root .g9-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

#game-root .g9-card-head h2 {
  margin: 0;
}

#game-root .g9-card-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

#game-root .g9-card-actions .g9-btn {
  flex: 1 1 88px;
  padding: 0 10px;
}

#game-root .g9-modes {
  display: flex;
  gap: 6px;
  width: min(100%, 700px);
  margin: 10px auto 0;
}

#game-root .g9-seg {
  flex: 1 1 0;
  min-width: 0;
  padding: 0 6px;
  font-size: 13px;
}

#game-root .g9-actions {
  display: flex;
  gap: 6px;
  width: min(100%, 700px);
  margin: 6px auto 0;
}

#game-root .g9-actions .g9-btn {
  flex: 1 1 0;
  min-width: 0;
  padding: 0 6px;
  font-size: 13px;
}

#game-root .g9-mirror {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 560px) {
  #game-root .g9-shell {
    padding: 8px;
    border-radius: 12px;
  }

  #game-root .g9-stat {
    padding: 4px 6px;
  }

  #game-root .g9-stat span {
    font-size: 9px;
  }

  #game-root .g9-stat strong {
    font-size: 14px;
  }

  #game-root .g9-status {
    margin: 6px 0;
    font-size: 13px;
  }

  #game-root .g9-seg,
  #game-root .g9-actions .g9-btn {
    font-size: 12px;
  }
}

@media (pointer: coarse) {
  #game-root .g9-canvas {
    cursor: default;
  }
}
