/*
 * This is a manifest file that'll be compiled into application.css, which will include all the files
 * listed below.
 *
 * Any CSS (and SCSS, if configured) file within this directory, lib/assets/stylesheets, or any plugin's
 * vendor/assets/stylesheets directory can be referenced here using a relative path.
 *
 * You're free to add application-wide styles to this file and they'll appear at the bottom of the
 * compiled file so the styles you add here take precedence over styles defined in any other CSS
 * files in this directory. Styles in this file should be added after the last require_* statement.
 * It is generally better to create a new file per style scope.
 *


 */

:root {
  --ink: #2b2350;
  --muted: #6a6288;
  --paper: #fffdf8;
  --sky: #fff4e0;
  --teal: #52dcae;
  --hot-pink: #ff1493;
  --pink: #ff5d8f;
  --purple: #6c4dff;
  --sun: #ffc93c;
  --line: #2b2350;
  --x-red: #e0192d;
  --o-blue: #1464e6;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background-color: var(--teal);
  background-image: radial-gradient(rgba(108, 77, 255, 0.8) 2px, transparent 2px);
  background-size: 24px 24px;
  font-family: ui-rounded, "SF Pro Rounded", "Trebuchet MS", "Segoe UI", sans-serif;
  font-size: 1.0625rem;
  line-height: 1.6;
}

h1 {
  margin: 0 0 1rem;
  font-size: clamp(2.25rem, 7vw, 3.25rem);
  line-height: 1.1;
  letter-spacing: -0.01em;
}

a {
  color: var(--purple);
}

/* Header */

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  padding: 1rem clamp(1rem, 4vw, 2.5rem);
  background: var(--paper);
  border-bottom: 3px solid var(--line);
}

.brand {
  color: var(--pink);
  font-size: 1.5rem;
  font-weight: 800;
  text-decoration: none;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.site-nav a {
  padding: 0.3rem 0.85rem;
  border-radius: 999px;
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
  transition: background-color 0.15s ease;
}

.site-nav a:hover {
  background: var(--sky);
}

.site-nav a.active {
  background: var(--sun);
}

/* Page */

.page {
  max-width: 48rem;
  margin: 0 auto;
  padding: clamp(2rem, 6vw, 4rem) 1rem;
}

.lead {
  margin: 0 0 1.5rem;
  color: var(--ink);
  font-size: 1.25rem;
}

.card {
  padding: 1.5rem;
  background: var(--paper);
  border: 3px solid var(--line);
  border-radius: 1.25rem;
  box-shadow: 6px 6px 0 var(--line);
}

/* Home */

.hero {
  padding-block: clamp(1rem, 6vw, 3rem);
  text-align: center;
}

.hero h1,
.pink-title {
  color: var(--hot-pink);
  text-shadow: 3px 3px 0 var(--line);
}

.hero h1 {
  font-size: clamp(2.75rem, 10vw, 4.5rem);
}

.hero-bubble {
  display: inline-block;
  max-width: 100%;
  margin-bottom: 2rem;
  padding: 1.5rem clamp(1.25rem, 5vw, 3rem);
  background: var(--sun);
  border: 3px solid var(--line);
  border-radius: 2.5rem;
  box-shadow: 6px 6px 0 var(--line);
}

.hero p {
  margin: 0;
  color: var(--ink);
  font-size: 1.35rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
}

.button {
  display: inline-block;
  padding: 0.65rem 1.5rem;
  background: var(--pink);
  border: 3px solid var(--line);
  border-radius: 999px;
  box-shadow: 4px 4px 0 var(--line);
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.button:hover {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 var(--line);
}

.button-alt {
  background: var(--paper);
  color: var(--ink);
}

/* About */

.card .lead {
  color: var(--ink);
  font-weight: 700;
}

.facts {
  display: grid;
  gap: 1rem;
  margin: 0;
}

.facts div {
  padding: 0.75rem 1rem;
  background: var(--sky);
  border-radius: 0.75rem;
}

.facts dt {
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 700;
}

.facts dd {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.facts dd a {
  font-size: min(1.05rem, 3.7vw);
}

/* Games */

.table-wrap {
  padding: 0;
  overflow-x: auto;
}

.games-table {
  width: 100%;
  border-collapse: collapse;
}

.games-table th {
  padding: 0.75rem 1.25rem;
  background: var(--purple);
  color: #fff;
  text-align: left;
}

.games-table td {
  height: 3.25rem;
  padding: 0.75rem 1.25rem;
  border-top: 2px solid var(--sky);
}

.games-table tbody tr:hover {
  background: var(--sky);
}

/* Game pages */

.game-intro {
  text-align: center;
}

.back-link {
  margin: 1.75rem 0 0;
  text-align: center;
}

.back-link a {
  color: var(--ink);
  font-weight: 700;
}

/* Shark Game */

.game {
  position: relative;
  overflow: hidden;
  border: 3px solid var(--line);
  border-radius: 1.25rem;
  box-shadow: 6px 6px 0 var(--line);
}

/* The arrow keys can't scroll during play, so the whole board has to fit on screen. */
.page > .game,
.racing-game {
  max-width: max(20rem, (100vh - 19rem) * 1.66);
  margin-inline: auto;
}

.game-canvas {
  display: block;
  width: 100%;
  aspect-ratio: 5 / 3;
  touch-action: none;
}

.game-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1rem;
  background: rgba(11, 79, 158, 0.65);
  color: #fff;
  text-align: center;
}

.game-overlay[hidden] {
  display: none;
}

.game-overlay h2,
.game-overlay p {
  margin: 0;
}

.game-overlay h2 {
  font-size: clamp(1.75rem, 6vw, 2.5rem);
  line-height: 1.1;
}

button.button {
  cursor: pointer;
  font: inherit;
  font-weight: 700;
}

.game-help {
  margin: 1.75rem 0 1rem;
  padding: 0;
  list-style: none;
  text-align: center;
}

/* Tic Tac Toe */

.ttt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
}

.ttt-mode {
  display: flex;
  gap: 0.25rem;
  padding: 0.25rem;
  background: var(--paper);
  border: 3px solid var(--line);
  border-radius: 999px;
}

.ttt-mode button {
  padding: 0.3rem 1rem;
  background: none;
  border: 0;
  border-radius: 999px;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
}

.ttt-mode button[aria-pressed="true"] {
  background: var(--sun);
}

.ttt-status {
  margin: 0;
  padding: 0.1rem 1.25rem;
  background: var(--paper);
  border: 3px solid var(--line);
  border-radius: 999px;
  font-size: 1.75rem;
  font-weight: 800;
}

.ttt-board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
  width: min(100%, 24rem);
  padding: 0.6rem;
  background: var(--line);
  border-radius: 1.25rem;
  box-shadow: 6px 6px 0 var(--sun);
}

.ttt-cell {
  aspect-ratio: 1;
  padding: 0;
  background: var(--paper);
  border: 0;
  border-radius: 0.75rem;
  cursor: pointer;
  font: inherit;
  font-size: clamp(3rem, 16vw, 5rem);
  font-weight: 800;
  line-height: 1;
  transition: background-color 0.15s ease;
}

.ttt-cell:hover:enabled {
  background: var(--sky);
}

.ttt-cell:disabled {
  cursor: default;
}

.ttt-cell.winning {
  background: var(--sun);
}

.mark-x {
  color: var(--x-red);
}

.mark-o {
  color: var(--o-blue);
}

/* Snake */

/* The arrow keys can't scroll during play, so the whole board has to fit on screen. */
.snake-game {
  max-width: min(30rem, max(18rem, 100vh - 21rem));
  margin-inline: auto;
}

.snake-game .game-canvas {
  aspect-ratio: 1;
}

.snake-score {
  margin: 0 0 0.75rem;
  font-size: 1.25rem;
  font-weight: 800;
  text-align: center;
}

/* Racing Game */

.racing-status {
  min-height: 1.6em;
  margin: 1.25rem 0 0.75rem;
  font-weight: 700;
  text-align: center;
}

.racing-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.racing-panel[hidden],
.racing-touch[hidden] {
  display: none;
}

.racing-options {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem 2.5rem;
  max-width: 100%;
}

.racing-field {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  max-width: 100%;
  font-weight: 700;
}

.racing-field select,
.racing-field input[type="text"] {
  width: min(18rem, 100%);
  padding: 0.4rem 0.75rem;
  background: var(--paper);
  border: 3px solid var(--line);
  border-radius: 0.75rem;
  color: var(--ink);
  font: inherit;
}

.racing-colors {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
}

.racing-swatch,
.racing-custom-color {
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border: 3px solid var(--line);
  border-radius: 50%;
  cursor: pointer;
}

.racing-custom-color {
  overflow: hidden;
  background: var(--paper);
}

.racing-swatch[aria-pressed="true"] {
  outline: 3px solid var(--line);
  outline-offset: 2px;
}

.racing-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
}

button.button:disabled {
  box-shadow: none;
  cursor: default;
  opacity: 0.45;
  transform: none;
}

/* Driving buttons only show on touchscreens. */
.racing-touch {
  display: none;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin-bottom: 1rem;
}

@media (pointer: coarse) {
  .racing-touch {
    display: grid;
  }
}

.racing-touch button {
  padding-block: 1.1rem;
  background: var(--paper);
  border: 3px solid var(--line);
  border-radius: 0.75rem;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

/* Piano */

.piano-now {
  min-height: 1.6em;
  margin: 0 0 0.75rem;
  font-size: 1.5rem;
  font-weight: 800;
  text-align: center;
}

.piano {
  position: relative;
  display: flex;
  height: clamp(11rem, 40vh, 16rem);
  padding: 0.5rem;
  background: var(--line);
  border-radius: 1rem;
  box-shadow: 6px 6px 0 var(--sun);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.piano-key {
  flex: 1;
  min-width: 0;
  padding: 0 0 0.6rem;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 0 0 0.4rem 0.4rem;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-size: clamp(0.8rem, 2.6vw, 1.15rem);
  font-weight: 800;
  touch-action: none;
}

.piano-key.active {
  background: var(--sun);
}

.piano-key-black {
  position: absolute;
  top: 0.5rem;
  left: calc(0.5rem + (100% - 1rem) / var(--white-keys) * var(--position));
  z-index: 1;
  width: calc((100% - 1rem) / var(--white-keys) * 0.66);
  height: 60%;
  padding-bottom: 0.4rem;
  background: var(--line);
  border-color: #000;
  color: #fff;
  font-size: clamp(0.55rem, 1.7vw, 0.8rem);
  transform: translateX(-50%);
}

.piano-key-black.active {
  background: var(--pink);
}

.piano-recorder {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 1.75rem;
  text-align: center;
}

.button.recording {
  background: var(--x-red);
}

.piano-record-status {
  min-height: 1.6em;
  margin: 0.75rem 0;
  font-weight: 700;
}

.piano-draft {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.piano-draft[hidden] {
  display: none;
}

.piano-songs-title {
  margin: 1.5rem 0 0.5rem;
}

.piano-songs {
  width: min(100%, 32rem);
  margin: 0;
  padding: 0;
  list-style: none;
}

.piano-song {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin-bottom: 0.75rem;
  padding: 0.6rem 0.9rem;
  background: var(--paper);
  border: 3px solid var(--line);
  border-radius: 0.9rem;
}

.piano-song-name {
  flex: 1;
  min-width: 5.5rem;
  font-weight: 700;
  overflow-wrap: anywhere;
  text-align: left;
}

.piano-song-length {
  color: var(--muted);
}

.piano-song-button {
  padding: 0.25rem 0.8rem;
  background: var(--sky);
  border: 2px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
}

.piano-song-button:disabled {
  cursor: default;
  opacity: 0.45;
}
