:root {
  --ink: #16120e;
  --muted: #776c60;
  --soft: #fff7e8;
  --card: rgba(255, 252, 245, 0.88);
  --line: rgba(22, 18, 14, 0.13);
  --orange: #ff7a00;
  --orange-dark: #e85800;
  --yellow: #ffd45c;
  --blue: #0f75bc;
  --shadow: 0 24px 70px rgba(48, 30, 8, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: Arial, sans-serif;
  background:
    radial-gradient(circle at 10% 12%, rgba(255, 212, 92, 0.72), transparent 25%),
    radial-gradient(circle at 88% 12%, rgba(255, 122, 0, 0.34), transparent 28%),
    radial-gradient(circle at 50% 105%, rgba(15, 117, 188, 0.18), transparent 36%),
    linear-gradient(135deg, #fff4da 0%, #f7efe4 50%, #eaf3ff 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(22, 18, 14, 0.042) 1px, transparent 1px),
    linear-gradient(90deg, rgba(22, 18, 14, 0.042) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(to bottom, black, transparent 80%);
}

.app {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 24px 0 42px;
}

.hidden {
  display: none !important;
}

.screen {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 38px;
  background: var(--card);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.home-screen {
  min-height: calc(100vh - 72px);
  max-height: calc(100vh - 72px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: clamp(24px, 5vw, 58px);
  align-items: center;
  padding: clamp(26px, 5vw, 56px);
}

.language-picker {
  position: absolute;
  top: 24px;
  right: 26px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 2px solid rgba(22, 18, 14, 0.16);
  border-radius: 19px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 12px 30px rgba(22, 18, 14, 0.14);
}

.language-picker label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 950;
  text-transform: uppercase;
}

.language-picker select {
  border: none;
  background: transparent;
  color: var(--ink);
  font-size: 16px;
  font-weight: 950;
  outline: none;
  cursor: pointer;
}

.home-content {
  min-width: 0;
}

.home-header {
  display: flex;
  align-items: flex-start;
  gap: 18px;
}

.eyebrow,
.mini-heading,
.card-label {
  margin: 0 0 9px;
  color: var(--orange-dark);
  font-size: 12px;
  font-weight: 950;
  letter-spacing: 1.7px;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  font-weight: 950;
  letter-spacing: -1.7px;
  line-height: 0.96;
}

h1 {
  font-size: clamp(50px, 8.2vw, 108px);
}

h1 span {
  color: var(--orange);
}

h2 {
  font-size: clamp(32px, 4.8vw, 62px);
}

.home-intro {
  max-width: 700px;
  margin-top: clamp(30px, 6vh, 54px);
}

.home-intro p {
  max-width: 600px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: clamp(17px, 2vw, 21px);
  line-height: 1.55;
}

.home-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: clamp(28px, 6vh, 52px);
}

button {
  border: none;
  min-height: 54px;
  padding: 14px 22px;
  border-radius: 17px;
  background: var(--ink);
  color: white;
  font-size: 15px;
  font-weight: 950;
  cursor: pointer;
  box-shadow: 0 8px 0 rgba(22, 18, 14, 0.16);
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

button:hover {
  background: var(--orange);
  transform: translateY(-2px);
  box-shadow: 0 12px 0 rgba(22, 18, 14, 0.12);
}

button:active {
  transform: translateY(2px);
  box-shadow: 0 4px 0 rgba(22, 18, 14, 0.16);
}

.button-primary {
  min-width: 168px;
  background: linear-gradient(135deg, var(--orange), var(--orange-dark));
}

.button-secondary,
.back {
  background: white;
  color: var(--ink);
  border: 2px solid var(--line);
}

.home-card-wrap {
  min-width: 0;
  display: grid;
  justify-items: center;
  align-content: center;
}

.home-preview-card {
  display: grid;
  place-items: center;
  width: 100%;
}

.home-preview-card .game-card {
  transform: rotate(3deg);
}

.makerworld-link {
  position: absolute;
  right: 28px;
  bottom: 24px;
  z-index: 3;
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
  text-decoration: none;
  box-shadow: 0 10px 28px rgba(22, 18, 14, 0.12);
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.makerworld-link:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 34px rgba(22, 18, 14, 0.16);
}

.makerworld-link span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.makerworld-link strong {
  color: var(--orange-dark);
  font-size: 15px;
  font-weight: 950;
}

.page-header {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  align-items: start;
  padding: clamp(18px, 3vw, 28px) clamp(22px, 4vw, 42px) 0;
}

#play {
  min-height: calc(100vh - 72px);
  display: flex;
  flex-direction: column;
}

.page-header h2 {
  max-width: 860px;
  font-size: clamp(30px, 4vw, 54px);
}

.play-board {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(330px, 1fr) 380px;
  gap: 24px;
  padding: 18px clamp(22px, 4vw, 42px) clamp(18px, 3vw, 28px);
}

.play-card-area,
.play-sidebar,
.creator-card,
.scoreboard,
.timer-card,
.palette-panel,
.grid-panel {
  border: 1px solid var(--line);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.68);
}

.play-card-area {
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 22px;
  background:
    radial-gradient(circle at center, rgba(255, 122, 0, 0.12), transparent 34%),
    rgba(255, 255, 255, 0.58);
}

.play-card-slot {
  width: min(300px, 100%);
  min-height: 390px;
  display: grid;
  place-items: center;
}

.play-card-slot:empty::before {
  content: attr(data-empty);
  display: grid;
  place-items: center;
  width: min(300px, 74vw);
  height: 390px;
  border: 4px dashed rgba(22, 18, 14, 0.18);
  border-radius: 30px;
  color: var(--muted);
  font-weight: 950;
  text-transform: uppercase;
}

.play-sidebar {
  display: grid;
  gap: 12px;
  align-content: start;
  padding: 18px;
}

.timer-card {
  padding: 14px;
  text-align: center;
  background: var(--ink);
  color: white;
}

.timer-card span {
  color: var(--yellow);
  font-weight: 950;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.timer {
  margin: 8px 0 0;
  font-size: clamp(58px, 8vw, 82px);
  font-weight: 950;
  line-height: 0.9;
}

.timer-card small {
  color: rgba(255, 255, 255, 0.72);
  font-weight: 850;
}

.action-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.action-grid button {
  width: 100%;
}

.scoreboard {
  padding: 14px;
}

.scoreboard h3 {
  margin: 0 0 8px;
  font-size: 23px;
}

.player {
  display: grid;
  grid-template-columns: 1fr 48px 54px 48px;
  gap: 9px;
  align-items: center;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}

.player span {
  font-weight: 950;
}

.player strong {
  text-align: center;
  font-size: 24px;
}

.player button {
  min-height: 40px;
  padding: 0;
}

.centered-header {
  justify-items: center;
}

.centered-header .back {
  justify-self: start;
}

.centered-header > div {
  text-align: center;
}

.creator-shell {
  display: grid;
  justify-items: center;
  padding: 26px clamp(18px, 4vw, 42px) 0;
}

.creator-card {
  width: min(100%, 980px);
  padding: clamp(18px, 3vw, 28px);
}

.title-row {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 14px;
  align-items: center;
}

.field-label,
.setting-box label {
  color: var(--muted);
  font-size: 14px;
  font-weight: 950;
  letter-spacing: 1px;
  text-transform: uppercase;
}

input {
  width: 100%;
  min-height: 54px;
  padding: 15px 18px;
  border: 2px solid var(--line);
  border-radius: 18px;
  background: white;
  color: var(--ink);
  font-size: 16px;
  font-weight: 850;
  outline: none;
}

input:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 5px rgba(255, 122, 0, 0.12);
}

.settings {
  display: grid;
  grid-template-columns: 1.1fr 1fr 1.35fr;
  gap: 14px;
  margin-top: 18px;
}

.setting-box {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 248, 234, 0.75);
  overflow-x: auto;
}

.choice-row {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  margin-top: 10px;
}

.choice {
  min-height: 40px;
  min-width: 44px;
  padding: 9px 11px;
  border: 2px solid transparent;
  background: white;
  color: var(--ink);
  box-shadow: none;
}

.choice.active {
  background: var(--orange);
  color: white;
  border-color: var(--ink);
}

.studio-workspace {
  display: grid;
  grid-template-columns: 1fr;
  margin-top: 18px;
}

.palette-panel,
.grid-panel {
  padding: 18px;
}

.palette-panel {
  margin-top: 18px;
}

.colors {
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  gap: 11px;
}

.colors button {
  width: 46px;
  height: 46px;
  min-height: 46px;
  padding: 0;
  border: 3px solid white;
  border-radius: 15px;
  box-shadow: 0 5px 0 rgba(22, 18, 14, 0.18);
}

.eraser {
  background: white !important;
  color: var(--ink);
}

.grid-panel {
  display: grid;
  justify-items: center;
}

.grid {
  display: grid;
  grid-template-columns: repeat(8, 34px);
  grid-template-rows: repeat(8, 34px);
  gap: 5px;
  justify-content: center;
  width: fit-content;
  margin-top: 8px;
  padding: 14px;
  border-radius: 24px;
  background: var(--ink);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.08), 0 16px 34px rgba(22, 18, 14, 0.18);
}

.cell {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(22, 18, 14, 0.16);
  border-radius: 8px;
  background: white;
  cursor: pointer;
  box-shadow: inset 3px 3px 0 rgba(255, 255, 255, 0.55), inset -2px -2px 0 rgba(0, 0, 0, 0.12);
}

.creator-actions {
  grid-template-columns: repeat(3, 1fr);
  margin-top: 18px;
}

.collection-section {
  padding: 34px clamp(18px, 4vw, 42px) clamp(22px, 4vw, 42px);
}

.collection-header {
  margin-bottom: 18px;
  text-align: center;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 26px;
}

.game-card {
  position: relative;
  width: 300px;
  height: 450px;
  margin: auto;
  overflow: hidden;
  border: 6px solid #ff7a00;
  border-radius: 30px;
  background: white;
  box-shadow: 0 14px 35px rgba(0, 0, 0, 0.18);
}

#play .game-card {
  transform: scale(var(--play-card-scale, 0.9));
}

#play .play-card-slot {
  overflow: visible;
}

.card-header {
  height: 56px;
  padding-left: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #111;
  color: white;
  font-size: 18px;
  font-weight: 900;
}

.card-header span {
  color: #ff7a00;
}

.card-number {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 10;
  width: 75px;
  height: 75px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0 0 24px 0;
  background: #ff7a00;
  color: white;
  font-size: 32px;
  font-weight: 900;
}

.card-title {
  position: relative;
  z-index: 5;
  margin-top: 18px;
  padding: 0 18px;
  font-size: 22px;
  font-weight: 900;
  text-align: center;
  text-transform: uppercase;
}

.model-area {
  position: relative;
  height: 250px;
  margin-top: -15px;
}

.block {
  position: absolute;
  width: 25px;
  height: 25px;
  border-radius: 5px;
  box-shadow:
    4px 5px 0 rgba(0, 0, 0, 0.22),
    inset 3px 3px 0 rgba(255, 255, 255, 0.35),
    inset -3px -3px 0 rgba(0, 0, 0, 0.18);
}

.card-bottom {
  position: absolute;
  right: 0;
  bottom: 48px;
  left: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  padding: 0 22px;
  background: white;
}

.stars {
  color: #ffc400;
  font-size: 24px;
  text-align: left;
}

.time {
  font-size: 24px;
  font-weight: 900;
  text-align: right;
}

.points {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ff7a00;
  color: white;
  font-size: 24px;
  font-weight: 900;
}

.delete-mode {
  outline: 7px solid #e32626;
  outline-offset: 4px;
}

.delete-mode.can-delete {
  outline-color: #19a85b;
}

.message-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(22, 18, 14, 0.42);
  backdrop-filter: blur(8px);
}

.message-box {
  width: min(420px, 100%);
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 28px;
  background: #fffaf0;
  box-shadow: 0 24px 70px rgba(22, 18, 14, 0.28);
  text-align: center;
}

.message-box h3 {
  margin: 0 0 8px;
  font-size: 26px;
}

.message-box p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.message-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 20px;
}

@media (max-width: 980px) {
  #play {
    min-height: auto;
  }

  #play .game-card {
    transform: none;
  }

  .home-screen {
    max-height: none;
    min-height: auto;
    grid-template-columns: 1fr;
  }

  .home-preview-card .game-card {
    transform: none;
  }

  .play-board,
  .studio-workspace {
    grid-template-columns: 1fr;
  }

  .palette-panel {
    display: grid;
    justify-items: center;
  }

  .colors {
    flex-wrap: wrap;
    justify-content: center;
  }
}

@media (min-width: 981px) and (max-height: 780px) {
  :root {
    --play-card-scale: 0.82;
  }

  .app {
    padding-top: 14px;
    padding-bottom: 14px;
  }

  #play {
    min-height: calc(100vh - 28px);
  }

  .page-header {
    padding-top: 18px;
    gap: 10px;
  }

  .page-header h2 {
    font-size: clamp(26px, 3.4vw, 44px);
  }

  .play-board {
    gap: 18px;
    padding-top: 12px;
    padding-bottom: 18px;
  }

  .play-card-slot {
    min-height: 350px;
  }

  .play-card-area {
    padding: 10px;
  }

  .play-sidebar {
    gap: 10px;
    padding: 14px;
  }

  .timer-card {
    padding: 12px;
  }

  .timer {
    font-size: clamp(52px, 7vw, 72px);
  }

  button {
    min-height: 46px;
    padding-top: 10px;
    padding-bottom: 10px;
  }

  .scoreboard {
    padding: 12px;
  }

  .scoreboard h3 {
    font-size: 20px;
  }

  .player {
    padding: 6px 0;
  }
}

@media (min-width: 981px) and (max-height: 650px) {
  :root {
    --play-card-scale: 0.72;
  }

  #play {
    min-height: auto;
  }

  .play-card-slot {
    min-height: 315px;
  }

  .page-header h2 {
    font-size: clamp(24px, 3vw, 36px);
  }

  .timer {
    font-size: 56px;
  }
}

@media (max-width: 700px) {
  .app {
    width: min(100% - 18px, 1180px);
    padding-top: 10px;
  }

  .screen {
    border-radius: 26px;
  }

  .home-screen,
  .panel {
    padding: 20px;
  }

  .language-picker {
    position: static;
    justify-content: center;
    margin-bottom: 16px;
  }

  .home-header,
  .page-header,
  .centered-header {
    grid-template-columns: 1fr;
    display: grid;
  }

  .home-header {
    gap: 14px;
  }

  h1 {
    font-size: clamp(42px, 15vw, 72px);
  }

  .home-intro {
    margin-top: 26px;
  }

  .home-actions {
    margin-top: 24px;
  }

  .home-actions button,
  .creator-actions {
    width: 100%;
  }

  .home-card-wrap {
    margin-top: 8px;
  }

  .home-preview-card .game-card {
    transform: scale(0.88);
    transform-origin: center top;
  }

  .makerworld-link {
    position: static;
    width: 100%;
    margin-top: 14px;
    align-items: center;
    text-align: center;
  }

  .page-header {
    padding: 20px 20px 0;
  }

  .centered-header > div {
    text-align: left;
  }

  .play-board,
  .creator-shell,
  .collection-section {
    padding-left: 20px;
    padding-right: 20px;
  }

  .play-card-area {
    min-height: 470px;
    padding: 12px;
  }

  .settings,
  .title-row,
  .creator-actions {
    grid-template-columns: 1fr;
  }

  .colors {
    flex-wrap: wrap;
    justify-content: center;
  }

  .grid {
    grid-template-columns: repeat(8, 28px);
    grid-template-rows: repeat(8, 28px);
    gap: 4px;
    padding: 10px;
  }

  .cell {
    width: 28px;
    height: 28px;
    border-radius: 7px;
  }

  .game-card {
    width: min(300px, 100%);
  }
}
