:root {
  --bg: #0f172a;
  --panel-2: #1f2937;
  --text: #e5e7eb;
  --border: rgba(255, 255, 255, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  padding: clamp(24px, 5vh, 56px) clamp(12px, 3vw, 40px);
  display: grid;
  place-items: center;
  overflow-x: hidden;
  overflow-y: auto;
  background: radial-gradient(circle at top, #1e293b 0%, var(--bg) 60%, #020817 100%);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

.app {
  width: max-content;
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 32px;
}

.sidebar {
  width: 420px;
  flex: 0 0 420px;
  min-width: 0;
}

.sidebar h1 {
  text-align: left;
  white-space: nowrap;
}

.intro {
  margin: -4px 0 18px;
  color: rgba(229, 231, 235, 0.7);
  font-size: 0.85rem;
  line-height: 1.45;
}

.disclaimer {
  margin: -10px 0 18px;
  color: rgba(229, 231, 235, 0.48);
  font-size: 0.72rem;
  line-height: 1.4;
}

.joke-ad {
  display: flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  margin: 8px 0 0 auto;
  padding: 5px 8px;
  border: 1px solid rgba(251, 191, 36, 0.25);
  border-radius: 5px;
  color: rgba(229, 231, 235, 0.62);
  font-size: 0.7rem;
  text-decoration: none;
}

.joke-ad:hover {
  border-color: rgba(251, 191, 36, 0.6);
  color: var(--text);
}

.joke-ad-label {
  color: #fbbf24;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

h1 {
  margin: 0 0 12px;
  text-align: center;
  font-size: clamp(1.3rem, 2vw, 2rem);
}

.controls {
  display: flex;
  justify-content: flex-start;
  gap: 10px;
  flex-wrap: nowrap;
  margin-bottom: 12px;
}

.settings-section {
  margin-bottom: 22px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.settings-section h2 {
  margin: 0 0 12px;
  color: rgba(229, 231, 235, 0.82);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.size-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 18px;
  color: var(--text);
  font-size: 0.85rem;
}

.size-control label {
  min-width: 72px;
  text-align: left;
}

.scale-control {
  margin-bottom: 18px;
  color: var(--text);
  font-size: 0.85rem;
}

.control-label {
  display: block;
  margin-bottom: 8px;
}

.scale-button {
  padding: 6px 8px;
  font-size: 0.72rem;
  max-width: 100%;
}

.scale-button.active {
  background: #059669;
  border-color: #10b981;
}

input[type="range"] {
  width: min(220px, 55vw);
  accent-color: #10b981;
}

button {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
}

.primary {
  background: linear-gradient(180deg, #10b981, #059669);
  border-color: transparent;
}

.board-wrap {
  width: max-content;
}

.board-shell {
  position: relative;
  width: max-content;
  max-width: 100%;
}

.fullscreen-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 10;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: var(--text);
  font-size: 1.1rem;
  line-height: 1;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.18);
}

.board {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  cursor: pointer;
  image-rendering: pixelated;
  touch-action: none;
}

body.fullscreen-mode {
  padding: 0;
  background: #020817;
}

body.fullscreen-mode .app {
  width: 100vw;
  max-width: none;
  min-height: 100vh;
  gap: 0;
  align-items: stretch;
  justify-content: center;
  padding: 0;
}

body.fullscreen-mode .sidebar {
  display: none;
}

body.fullscreen-mode .board-wrap {
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  overflow: hidden;
}

body.fullscreen-mode .board-shell {
  flex: 0 0 auto;
  max-width: none;
}

body.fullscreen-mode .board {
  max-width: none;
}

body.fullscreen-mode .joke-ad {
  display: none;
}

@media (max-width: 1000px) {
  body {
    display: block;
    padding: 24px 18px;
  }

  .app {
    width: 100%;
    flex-direction: column;
    align-items: center;
    gap: 24px;
  }

  .sidebar {
    width: min(100%, 560px);
    flex-basis: auto;
  }

  .board-wrap {
    width: 100%;
  }

  .board-shell {
    margin: 0 auto;
  }

  .joke-ad {
    margin-left: auto;
    margin-right: auto;
  }
}

@media (max-width: 560px) {
  body {
    padding: 18px 12px;
  }

  .app {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
  }

  .sidebar {
    display: contents;
  }

  .sidebar h1,
  .intro,
  .disclaimer,
  .controls,
  .settings-section {
    width: 100%;
  }

  .sidebar h1 {
    text-align: center;
    white-space: normal;
  }

  .controls {
    flex-wrap: wrap;
    justify-content: center;
  }

  .board-wrap {
    order: 1;
    margin-bottom: 24px;
  }

  .settings-section {
    order: 2;
  }

  .controls button {
    flex: 1 1 calc(50% - 10px);
    min-width: 0;
    min-height: 44px;
  }

  .size-control {
    align-items: flex-start;
    flex-wrap: wrap;
    margin-bottom: 14px;
  }

  .size-control label {
    flex: 1 0 100%;
  }

  input[type="range"] {
    flex: 1;
    width: auto;
    min-width: 0;
    min-height: 32px;
  }

  .sound-buttons {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
  }

  .sound-buttons .scale-button {
    min-height: 40px;
    padding: 6px 4px;
    font-size: 0.68rem;
  }

  .board-shell {
    max-width: 100%;
  }

  .board-wrap {
    min-width: 0;
  }

  .joke-ad {
    margin-left: auto;
    margin-right: auto;
  }
}
