html,
body {
  --ui-ink: #f1f5f9;
  --ui-line: #dbe4ef;
  --ui-line-dark: #7f8ea3;
  --ui-panel-top: #203754;
  --ui-panel-bottom: #122337;
  --ui-panel-shadow: rgba(7, 12, 20, 0.88);
  --ui-accent: #e4493a;
  --ui-accent-dark: #9f2b2b;
  --ui-accent-blue: #4f7cbf;
  --ui-accent-blue-dark: #2f527d;
  --ui-gold: #ffd166;
  --ui-surface: rgba(15, 24, 38, 0.96);
  margin: 0;
  height: 100%;
  overflow: hidden;
  background:
    radial-gradient(circle at top, #294d74 0%, #15253e 35%, #05070d 100%);
  touch-action: none;
  font-family: "Trebuchet MS", sans-serif;
  color: #f1faee;
}

* {
  box-sizing: border-box;
}

button,
input {
  font: inherit;
}

[hidden] {
  display: none !important;
}

#app {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

#game-canvas {
  position: absolute;
  top: 50%;
  left: 50%;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  transform: translate(-50%, -50%) scale(var(--scale, 1));
  transform-origin: center center;
  background: #1d3557;
  box-shadow: 0 20px 80px rgba(0, 0, 0, 0.55);
}

.overlay,
.rotate-msg {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.overlay {
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(4, 10, 18, 0.12), rgba(4, 10, 18, 0.36));
}

.overlay--active {
  pointer-events: auto;
}

.app-footer {
  position: absolute;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  font-size: 0.6rem;
  line-height: 1;
  letter-spacing: 0.08em;
  opacity: 0.55;
  text-transform: uppercase;
  pointer-events: none;
  z-index: 5;
  text-align: center;
}

.rotate-msg {
  background: rgba(5, 7, 13, 0.94);
  text-align: center;
  z-index: 20;
}

.rotate-msg__small {
  opacity: 0.7;
  font-size: 0.9rem;
}

.panel {
  width: min(360px, 100%);
  padding: 20px 16px 18px;
  border: 4px solid var(--ui-line);
  outline: 3px solid rgba(10, 17, 28, 0.9);
  outline-offset: -7px;
  background:
    linear-gradient(180deg, var(--ui-panel-top), var(--ui-panel-bottom));
  box-shadow:
    0 0 0 6px rgba(10, 17, 28, 0.34),
    8px 8px 0 0 var(--ui-panel-shadow);
  position: relative;
}

.panel::before {
  content: "";
  position: absolute;
  inset: 10px 10px auto;
  height: 6px;
  background:
    repeating-linear-gradient(
      90deg,
      var(--ui-gold) 0 12px,
      transparent 12px 18px
    );
  opacity: 0.95;
}

.panel__title {
  margin: 8px 0 14px;
  font-size: 2rem;
  line-height: 1;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-shadow: 3px 3px 0 rgba(10, 17, 28, 0.95);
}

.panel__subtitle,
.panel__text {
  text-align: center;
  margin: 10px 0 12px;
  line-height: 1.35;
  color: #edf4fb;
}

.panel__subtitle {
  font-size: 1rem;
}

.panel__text {
  font-size: 0.96rem;
}

.stack {
  display: grid;
  gap: 12px;
}

.button {
  border: 3px solid var(--ui-line);
  background: var(--ui-accent);
  color: var(--ui-ink);
  padding: 11px 14px;
  min-height: 48px;
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  box-shadow:
    inset 0 -4px 0 0 var(--ui-accent-dark),
    4px 4px 0 0 rgba(8, 12, 19, 0.75);
  text-align: left;
}

.button--secondary {
  background: var(--ui-accent-blue);
  box-shadow:
    inset 0 -4px 0 0 var(--ui-accent-blue-dark),
    4px 4px 0 0 rgba(8, 12, 19, 0.75);
}

.button--ghost {
  background: rgba(12, 20, 32, 0.92);
  box-shadow:
    inset 0 -4px 0 0 rgba(45, 60, 80, 0.95),
    4px 4px 0 0 rgba(8, 12, 19, 0.75);
}

.link-box {
  width: 100%;
  padding: 10px 12px;
  border: 3px solid var(--ui-line-dark);
  background:
    linear-gradient(180deg, rgba(24, 36, 54, 0.98), rgba(13, 20, 31, 0.98));
  box-shadow: inset 0 0 0 2px rgba(241, 245, 249, 0.08);
  overflow-wrap: anywhere;
  color: #dfe8f2;
  font-size: 0.92rem;
  line-height: 1.35;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding: 7px 10px;
  border: 3px solid var(--ui-line-dark);
  background: var(--ui-surface);
  text-transform: uppercase;
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  line-height: 1.2;
  box-shadow: 4px 4px 0 0 rgba(8, 12, 19, 0.58);
}

.status-pill::before {
  content: "";
  width: 9px;
  height: 9px;
  background: var(--ui-gold);
  box-shadow: 0 0 0 2px rgba(8, 12, 19, 0.85);
}

.status-pill[data-state="connected"]::before {
  background: #80ed99;
}

.status-pill[data-state="error"]::before {
  background: #ff6b6b;
}

.scoreline {
  display: flex;
  justify-content: space-between;
  margin: 18px 0;
  font-size: 1.2rem;
  gap: 12px;
  text-transform: uppercase;
  padding: 10px 12px;
  border: 3px solid var(--ui-line-dark);
  background: rgba(12, 20, 32, 0.84);
  box-shadow: inset 0 -4px 0 0 rgba(28, 42, 60, 0.9);
}

.result-word {
  margin: 0 0 16px;
  font-size: 2.3rem;
  line-height: 1;
  color: var(--ui-gold);
  text-transform: uppercase;
  text-shadow: 3px 3px 0 rgba(10, 17, 28, 0.95);
}

.small {
  font-size: 0.88rem;
  opacity: 0.9;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 3px solid rgba(241, 245, 249, 0.22);
  border-top-color: var(--ui-gold);
  border-right-color: var(--ui-line);
  animation: spin 0.8s linear infinite;
}

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

@media (max-width: 420px), (max-height: 760px) {
  .overlay,
  .rotate-msg {
    padding: 16px;
  }

  .panel {
    padding: 18px 14px 16px;
  }

  .panel__title {
    font-size: 1.8rem;
  }

  .panel__subtitle,
  .panel__text,
  .link-box {
    font-size: 0.92rem;
  }

  .button {
    padding: 10px 12px;
    min-height: 46px;
    font-size: 0.9rem;
  }

  .scoreline {
    font-size: 1.05rem;
  }
}
