/* Фон: abstract blue geometric — Vecteezy */
:root {
  --sponge: #fff176;
  --sponge-dark: #fdd835;
  --ocean-deep: #0277bd;
  --ocean-light: #b3e5fc;
  --sand: #fff9e6;
  --coral: #ff7043;
  --bubble-border: #01579b;
  --text-dark: #1a237e;
  --text-soft: #37474f;
  --white-90: rgba(255, 255, 255, 0.96);
  --bg-image: url("https://static.vecteezy.com/system/resources/previews/007/679/780/original/abstract-blue-geometric-shapes-background-free-vector.jpg");
}

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

html,
body {
  height: 100%;
  margin: 0;
}

body {
  font-family: "Nunito", system-ui, sans-serif;
  color: var(--text-dark);
  line-height: 1.45;
  position: relative;
}

.page-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background: var(--ocean-light) center / cover no-repeat;
  background-image: var(--bg-image);
}

.page-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(255, 249, 230, 0.22) 0%,
    rgba(179, 229, 252, 0.42) 40%,
    rgba(255, 255, 255, 0.32) 100%
  );
}

.app {
  min-height: 100%;
  max-width: 100%;
  padding: clamp(0.65rem, 1.2vw, 1rem) clamp(0.65rem, 1.2vw, 1rem) clamp(0.65rem, 1.2vw, 1rem)
    clamp(1rem, 2.4vw, 2rem);
  display: flex;
  flex-direction: column;
}

/* Две колонки: слева панель, справа большое поле */
.layout-main {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: clamp(0.45rem, 1vw, 1rem);
  flex: 1;
  min-height: min(calc(100vh - 2rem), 1100px);
}

.layout-sidebar {
  flex: 0 0 clamp(320px, 33vw, 460px);
  max-width: 500px;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  min-height: 0;
  overflow-y: auto;
  padding-left: clamp(0.25rem, 0.8vw, 0.65rem);
  padding-right: clamp(0.15rem, 0.5vw, 0.35rem);
}

.layout-game {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem;
}

.header {
  text-align: left;
}

.header h1 {
  margin: 0;
  font-family: "Fredoka", system-ui, sans-serif;
  font-size: clamp(1.95rem, 3.1vw, 2.65rem);
  font-weight: 700;
  color: var(--text-dark);
  text-shadow:
    2px 2px 0 #fff,
    3px 3px 0 rgba(1, 87, 155, 0.12);
  letter-spacing: 0.02em;
  line-height: 1.15;
}

.hint--rules {
  font-size: clamp(0.82rem, 1.15vw, 0.95rem);
  font-weight: 600;
  margin: 0;
  padding: 0.65rem 0.75rem;
  background: var(--white-90);
  border-radius: 14px;
  border: 3px dashed var(--ocean-deep);
  line-height: 1.5;
}

.panel {
  background: var(--white-90);
  border: 4px solid var(--bubble-border);
  border-radius: 18px;
  padding: 0.9rem 1rem;
  box-shadow:
    0 6px 0 rgba(1, 87, 155, 0.18),
    0 10px 28px rgba(0, 0, 0, 0.07);
}

.panel--controls {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.field span {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--bubble-border);
}

select {
  padding: 0.65rem 0.85rem;
  border-radius: 14px;
  border: 3px solid var(--ocean-deep);
  background: #fff;
  color: var(--text-dark);
  font-size: 1.05rem;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
}

.btn {
  padding: 0.75rem 1.15rem;
  border-radius: 16px;
  border: 4px solid var(--text-dark);
  background: #fff;
  color: var(--text-dark);
  font-family: "Fredoka", sans-serif;
  font-weight: 600;
  font-size: 1.05rem;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  box-shadow: 0 4px 0 var(--text-dark);
}

.btn--start-wide {
  width: 100%;
  padding: 1rem 1.35rem;
  font-size: clamp(1.2rem, 2.2vw, 1.5rem);
}

.btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 var(--text-dark);
}

.btn:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 2px 0 var(--text-dark);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: 0 2px 0 #999;
}

.btn--primary {
  background: linear-gradient(180deg, var(--sponge), var(--sponge-dark));
  border-color: #f57f17;
  color: #4e342e;
  box-shadow: 0 4px 0 #e65100;
}

.btn--primary:hover:not(:disabled) {
  box-shadow: 0 6px 0 #e65100;
}

.btn--ghost {
  margin-top: 0.35rem;
  width: 100%;
  font-size: 0.88rem;
  font-family: "Nunito", sans-serif;
  box-shadow: 0 3px 0 #78909c;
  border-width: 3px;
}

.btn--small {
  padding: 0.55rem;
}

.side-stats {
  padding: 0.75rem 0.65rem;
}

.stats--compact {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.stat-bubble {
  font-weight: 700;
  font-size: 0.85rem;
  line-height: 1.3;
  padding: 0.55rem 0.5rem;
  background: linear-gradient(180deg, #e1f5fe, #b3e5fc);
  border: 3px solid var(--ocean-deep);
  border-radius: 14px;
  color: var(--text-dark);
  text-align: center;
}

.stat-bubble strong {
  display: inline-block;
  margin-top: 0.2rem;
  color: var(--coral);
  font-size: clamp(1.35rem, 2.5vw, 1.75rem);
  font-weight: 800;
  line-height: 1.1;
}

.game-stage {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: min(90vh, 1080px);
}

.canvas-wrap {
  position: relative;
  --sidebar-gutter: clamp(300px, 30vw, 440px);
  --field-max: min(1200px, calc(100vw - var(--sidebar-gutter) - 2.5rem));
  width: min(96vmin, 96vh, var(--field-max));
  height: min(96vmin, 96vh, var(--field-max));
  max-width: 100%;
  max-height: min(96vh, 1200px);
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 22px;
  overflow: hidden;
  border: 6px solid var(--bubble-border);
  box-shadow:
    0 0 0 4px #fff,
    0 14px 0 rgba(1, 87, 155, 0.22),
    0 24px 48px rgba(0, 0, 0, 0.12);
  background: #fff;
}

#game {
  display: block;
  background: var(--sand);
  vertical-align: middle;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  background: rgba(255, 249, 230, 0.93);
  backdrop-filter: blur(6px);
  padding: 1.5rem;
  text-align: center;
}

.overlay.hidden {
  display: none;
}

.overlay__text {
  margin: 0;
  font-family: "Fredoka", sans-serif;
  font-size: clamp(1.35rem, 3vw, 1.95rem);
  font-weight: 600;
  color: var(--text-dark);
  max-width: 24ch;
}

.btn--overlay-big {
  padding: 1.15rem 2.5rem;
  font-size: clamp(1.3rem, 2.8vw, 1.65rem);
  min-width: 14rem;
}

kbd {
  display: inline-block;
  padding: 0.15rem 0.42rem;
  margin: 0 0.06rem;
  border-radius: 8px;
  background: linear-gradient(180deg, #fff, #e3f2fd);
  border: 2px solid var(--bubble-border);
  font-size: 0.78rem;
  font-family: inherit;
  font-weight: 700;
  box-shadow: 0 2px 0 var(--bubble-border);
}

.records {
  margin-top: auto;
  padding: 0.75rem 0.85rem;
}

.records h2 {
  margin: 0 0 0.5rem;
  font-family: "Fredoka", sans-serif;
  font-size: clamp(1rem, 1.4vw, 1.15rem);
  color: var(--bubble-border);
  font-weight: 700;
}

.records__list {
  margin: 0 0 0.45rem;
  padding-left: 1.2rem;
  font-size: clamp(0.85rem, 1.2vw, 0.95rem);
  font-weight: 600;
  color: var(--text-dark);
}

.records__list li {
  margin-bottom: 0.28rem;
}

.records__list .speed {
  color: var(--text-soft);
  font-size: 0.82rem;
  font-weight: 600;
}

.records__empty {
  color: var(--text-soft);
  font-size: 0.9rem;
  list-style: none;
  padding-left: 0;
  font-weight: 600;
}

.hidden {
  display: none !important;
}

/* Узкие экраны: сначала большое поле, под ним панель */
@media (max-width: 900px) {
  .layout-main {
    flex-direction: column;
    min-height: auto;
  }

  .layout-sidebar {
    flex: none;
    max-width: none;
    width: 100%;
    order: 2;
  }

  .layout-game {
    order: 1;
    min-height: auto;
  }

  .game-stage {
    min-height: auto;
  }

  .canvas-wrap {
    width: min(96vw, 96vmin);
    height: min(96vw, 96vmin);
    max-height: 85vh;
  }

  .header {
    text-align: center;
  }
}
