:root {
  --bg-color: #0f172a;
  --panel-bg: #020617;
  --accent: #38bdf8;
  --accent-soft: rgba(56, 189, 248, 0.12);
  --text-main: #e5e7eb;
  --text-sub: #9ca3af;
  --border-soft: rgba(148, 163, 184, 0.4);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: radial-gradient(circle at top left, #1e293b 0, #020617 55%, #000 100%);
  color: var(--text-main);
  display: flex;
  align-items: stretch;
  justify-content: center;
}

.layout {
  max-width: 1200px;
  width: 100%;
  padding: 12px 24px 24px;
  display: grid;
  grid-template-columns: minmax(260px, 1.1fr) minmax(480px, 1.6fr);
  gap: 24px;
}

.panel {
  background: linear-gradient(145deg, rgba(15, 23, 42, 0.95), rgba(15, 23, 42, 0.8));
  border-radius: 18px;
  border: 1px solid var(--border-soft);
  box-shadow:
    0 18px 45px rgba(15, 23, 42, 0.9),
    0 0 0 1px rgba(15, 23, 42, 0.7);
  padding: 20px 22px;
}

.panel-left {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.screen[hidden] {
  display: none;
}

.title {
  font-size: 2.4rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 12px;
}

.subtitle {
  font-size: 0.98rem;
  color: var(--text-sub);
  line-height: 1.6;
  margin-bottom: 18px;
}

.sub-note {
  font-size: 0.86rem;
  opacity: 0.9;
}

.hint {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background-color: var(--accent-soft);
  color: var(--accent);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition:
    background-color 0.16s ease,
    border-color 0.16s ease,
    transform 0.06s ease;
}

.primary-button {
  margin-top: 10px;
  background: radial-gradient(circle at top left, #38bdf8, #0ea5e9);
  color: #0b1120;
  border-color: rgba(56, 189, 248, 0.9);
}

.secondary-button {
  background: transparent;
  color: var(--text-main);
  border-color: rgba(148, 163, 184, 0.7);
}

.primary-button:hover,
.secondary-button:hover {
  transform: translateY(-1px);
}

.primary-button:active,
.secondary-button:active {
  transform: translateY(0);
}

.hud-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 0.9rem;
}

.hud-label {
  font-weight: 600;
  color: #e5e7eb;
}

.hud-value {
  color: #a5b4fc;
}

.stress-bar {
  position: relative;
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.6);
  overflow: hidden;
  margin-bottom: 12px;
}

.stress-bar-fill {
  position: absolute;
  inset: 0;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, #22c55e, #eab308, #ef4444);
  transition: width 0.08s ease-out;
}

.result-title {
  font-size: 1.4rem;
  margin-bottom: 8px;
}

.result-actions {
  margin-top: 16px;
  display: flex;
  gap: 10px;
}

.panel-right {
  display: flex;
  align-items: center;
  justify-content: center;
}

.ad-slot {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ad-slot-top {
  min-height: 60px;
  padding: 6px 0;
  background: rgba(15, 23, 42, 0.8);
  border-bottom: 1px solid rgba(30, 64, 175, 0.4);
}

.ad-slot-bottom {
  margin-top: 18px;
  padding-top: 8px;
  border-top: 1px solid rgba(30, 64, 175, 0.4);
}

#gameCanvas {
  width: 100%;
  height: auto;
  max-width: 800px;
  max-height: 600px;
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.7);
  background: radial-gradient(circle at top, #1f2937 0, #020617 60%);
  box-shadow:
    0 18px 40px rgba(15, 23, 42, 0.9),
    0 0 0 1px rgba(15, 23, 42, 0.8);
  display: block;
}

#gameCanvas.canvas-broken {
  border-color: rgba(248, 113, 113, 0.9);
  box-shadow:
    0 22px 46px rgba(127, 29, 29, 0.85),
    0 0 0 1px rgba(127, 29, 29, 0.8);
}

@keyframes canvas-shake {
  0% {
    transform: translate3d(0, 0, 0);
  }
  20% {
    transform: translate3d(-4px, 2px, 0);
  }
  40% {
    transform: translate3d(3px, -2px, 0);
  }
  60% {
    transform: translate3d(-3px, 1px, 0);
  }
  80% {
    transform: translate3d(2px, -1px, 0);
  }
  100% {
    transform: translate3d(0, 0, 0);
  }
}

#gameCanvas.canvas-shake {
  animation: canvas-shake 0.45s ease-in-out;
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
    padding: 16px;
  }

  .panel {
    padding: 18px 18px;
  }

  .title {
    font-size: 2rem;
  }
}
