:root {
  --bg-top: #f3efe7;
  --bg-bottom: #e3edf0;
  --panel: #fcfbf8;
  --line: rgba(53, 72, 83, 0.14);
  --text: #23313a;
  --muted: #5c6970;
  --accent: #2c748d;
  --accent-dark: #1d566a;
  --shadow: 0 14px 34px rgba(33, 48, 58, 0.1);
  --radius: 26px;
  --tube-width: min(9.2vh, 88px);
  --tube-height: min(32vh, 310px);
  --ball-size: calc(var(--tube-width) * 0.72);
  --font-main: "Trebuchet MS", "Segoe UI", Tahoma, sans-serif;
  --font-display: Georgia, "Times New Roman", serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  font-family: var(--font-main);
  color: var(--text);
  background: linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
}

body {
  min-height: 100vh;
  overflow: hidden;
}

.reload-hotspot {
  position: fixed;
  top: 0;
  right: 0;
  width: 96px;
  height: 96px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  opacity: 0.01;
  z-index: 20;
}

.page-shell {
  width: min(1920px, 100vw);
  min-height: 100vh;
  margin: 0 auto;
  padding: 10px 10px 32px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(315px, 390px) minmax(0, 1fr);
  gap: 12px;
  min-height: calc(100vh - 32px);
}

.panel-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 16px;
}

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: auto;
}

.side-main {
  display: grid;
  gap: 12px;
  align-content: start;
}

.eyebrow {
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent-dark);
  font-size: 0.85rem;
  font-weight: 700;
}

.brand-block h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2.35rem, 3.7vw, 4.2rem);
  line-height: 0.92;
}

button {
  border: none;
  border-radius: 18px;
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  padding: 15px 16px;
  transition: transform 0.14s ease, box-shadow 0.14s ease, filter 0.14s ease;
}

button:hover,
button:focus-visible {
  transform: translateY(-1px);
  filter: brightness(1.02);
  outline: none;
}

.primary-button {
  background: linear-gradient(180deg, var(--accent), var(--accent-dark));
  color: #fff;
  box-shadow: 0 16px 26px rgba(44, 116, 141, 0.25);
}

.secondary-button {
  background: #ffffff;
  color: var(--text);
  border: 1px solid var(--line);
  box-shadow: 0 8px 18px rgba(33, 48, 58, 0.06);
}

.secondary-button[aria-pressed="true"] {
  border-color: rgba(44, 116, 141, 0.48);
  background: #e9f6f8;
}

.exit-link {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: auto;
  min-height: 66px;
  border-radius: 18px;
  background: linear-gradient(180deg, #455560, #29353d);
  color: #ffffff;
  text-decoration: none;
  font-size: 1.15rem;
  font-weight: 700;
  box-shadow: 0 12px 22px rgba(33, 48, 58, 0.2);
}

.exit-link:hover,
.exit-link:focus-visible {
  filter: brightness(1.04);
  outline: none;
}

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

.action-wide {
  grid-column: 1 / -1;
}

.stats-card h2,
.info-card h2 {
  font-size: 1.1rem;
  margin: 0 0 8px;
}

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

.stat-box {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #ffffff;
  padding: 10px 12px;
  min-width: 0;
}

.stat-label {
  display: block;
  color: var(--muted);
  margin-bottom: 4px;
}

.stat-box strong {
  font-size: 1.45rem;
  line-height: 1;
}

.info-card p,
.status-message {
  margin: 0;
  color: var(--muted);
  line-height: 1.4;
}

.info-card p + p {
  margin-top: 8px;
}

.board-panel {
  display: grid;
  place-items: center;
  overflow: hidden;
}

.board-wrap {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 100%;
}

.board {
  display: grid;
  grid-template-columns: repeat(5, var(--tube-width));
  gap: 22px;
  justify-content: center;
  align-content: center;
  padding: 20px;
  max-width: 100%;
}

.tube {
  position: relative;
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 8px;
  width: var(--tube-width);
  height: var(--tube-height);
  padding: 14px 8px 18px;
  border: 4px solid rgba(35, 49, 58, 0.2);
  border-top: 0;
  border-radius: 0 0 36px 36px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.26), rgba(255, 255, 255, 0.72));
  box-shadow: inset 0 -8px 18px rgba(33, 48, 58, 0.08), 0 12px 22px rgba(33, 48, 58, 0.08);
}

.tube::before {
  content: "";
  position: absolute;
  left: -5px;
  right: -5px;
  top: -8px;
  height: 12px;
  border-radius: 999px;
  background: rgba(35, 49, 58, 0.18);
}

.tube.selected {
  outline: 5px solid #ffe28a;
  outline-offset: 5px;
}

.tube.target {
  outline: 5px solid #7fdc9f;
  outline-offset: 5px;
}

.tube.hint {
  outline: 5px solid #9fd9ff;
  outline-offset: 5px;
}

.ball {
  position: relative;
  display: grid;
  place-items: center;
  width: var(--ball-size);
  height: var(--ball-size);
  border-radius: 50%;
  box-shadow: inset -8px -10px 16px rgba(0, 0, 0, 0.18), inset 6px 8px 12px rgba(255, 255, 255, 0.35), 0 6px 10px rgba(33, 48, 58, 0.16);
}

.ball::after {
  color: rgba(255, 255, 255, 0.9);
  font-size: calc(var(--ball-size) * 0.42);
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
}

.ball-red { background: #c81e3a; }
.ball-red::after { content: "●"; }
.ball-blue { background: #155cc7; }
.ball-blue::after { content: "◆"; }
.ball-green { background: #16803d; }
.ball-green::after { content: "▲"; }
.ball-yellow { background: #f0c400; }
.ball-yellow::after { content: "✚"; color: rgba(42, 42, 42, 0.72); text-shadow: none; }
.ball-purple { background: #7b35bd; }
.ball-purple::after { content: "★"; }
.ball-orange { background: #db6b16; }
.ball-orange::after { content: "■"; }
.ball-teal { background: #008c95; }
.ball-teal::after { content: "✦"; }
.ball-pink { background: #d32786; }
.ball-pink::after { content: "♥"; }

@media (max-width: 1380px) {
  :root {
    --tube-width: min(8.3vh, 76px);
    --tube-height: min(29vh, 264px);
  }

  .board {
    gap: 16px;
  }
}

@media (max-width: 1080px) {
  body {
    overflow: auto;
  }

  .layout {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .actions-block,
  .stat-grid {
    grid-template-columns: 1fr;
  }

  :root {
    --tube-width: min(13vw, 82px);
    --tube-height: min(34vw, 250px);
  }
}

@media (max-width: 720px) {
  :root {
    --tube-width: min(17vw, 64px);
    --tube-height: min(46vw, 220px);
  }

  .page-shell {
    width: min(100%, calc(100% - 16px));
    padding: 10px 8px;
  }

  .panel-card {
    padding: 16px;
  }

  .board {
    grid-template-columns: repeat(4, var(--tube-width));
    gap: 12px;
    padding: 12px;
  }
}
