:root {
  --app-shell-max-width: 1312px;
  --app-shell-padding: 14px;
  --layout-content-max-width: 1320px;
  --layout-content-padding: 16px;
  --layout-section-gap: 14px;
  --layout-header-gap: 16px;
  --layout-header-height: 88px;
  --layout-logo-width: 176px;
  --layout-logo-height: 84px;
  --layout-title-max-width: 620px;
  --layout-crafting-max-height: 860px;
  --layout-viewport-edge-gap: 8px;
  --layout-footer-min-height: 68px;
  --layout-side-column-width: 270px;
  --layout-workspace-gap: 18px;
  --layout-footer-action-width: 184px;
  --layout-footer-action-min-height: 62px;
  --layout-toolbar-padding: 12px;
  --layout-instruction-padding: 12px 18px;
  --layout-panel-border-width: 5px;
  --layout-panel-radius: 22px;
  --ink: #2b211c;
  --muted: #725b50;
  --cream: #faf1dc;
  --cream-2: #efe2c8;
  --panel: #fff8ea;
  --glass: rgba(255, 255, 255, 0.14);
  --glass-border: rgba(255, 248, 234, 0.28);
  --title-frame: rgba(255, 248, 234, 0.055);
  --title-frame-border: rgba(255, 248, 234, 0.38);
  --title-inner: rgba(255, 248, 234, 0.22);
  --terracotta: #c85a3a;
  --terracotta-dark: #99412f;
  --brown: #4a3225;
  --orange: #ff7b30;
  --gold: #f4be45;
  --teal: #2f9f9a;
  --blue: #4e9fdf;
  --green: #82c840;
  --purple: #c68ce0;
  --line: #4a3225;
  --shadow-hard: 0 7px 0 rgba(43, 33, 28, 0.28);
  --shadow-soft: 0 18px 38px rgba(43, 33, 28, 0.18);
  --glass-shadow: inset 0 0 0 2px rgba(255, 248, 234, 0.08), 0 28px 70px rgba(78, 32, 20, 0.26);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--terracotta) url("/title-screen-v2.png") center / cover no-repeat fixed;
  font-family:
    "Hiragino Maru Gothic ProN", "Hiragino Sans", "Yu Gothic", "Meiryo", ui-sans-serif, system-ui,
    sans-serif;
  overflow-x: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 12px;
  font-family: "Hiragino Maru Gothic ProN", "Yu Gothic", "Meiryo", sans-serif;
  font-size: clamp(2.1rem, 5vw, 4.6rem);
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 10px;
  color: var(--brown);
  font-size: 1.35rem;
  font-weight: 900;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 8px;
  font-size: 1rem;
  font-weight: 900;
  letter-spacing: 0;
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(var(--app-shell-max-width), 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: var(--app-shell-padding);
}

.app-shell::before {
  position: absolute;
  z-index: 0;
  inset: var(--app-shell-padding);
  border: 1px solid rgba(255, 248, 234, 0.12);
  border-radius: 20px;
  background: transparent;
  box-shadow: none;
  content: "";
  pointer-events: none;
}

.app-shell > * {
  position: relative;
  z-index: 1;
}

.loading-panel,
.entry-panel {
  width: min(560px, calc(100vw - 32px));
  margin: 11vh auto 0;
  padding: 28px;
  border: 4px solid var(--brown);
  border-radius: 22px;
  background: rgba(255, 248, 234, 0.9);
  box-shadow: var(--shadow-hard), var(--shadow-soft);
}

.mark {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border: 3px solid var(--brown);
  border-radius: 18px;
  background: var(--orange);
  color: #fff;
  font-weight: 900;
  box-shadow: inset -8px -10px 18px rgba(74, 50, 37, 0.18);
}

.title-screen {
  position: relative;
  display: grid;
  width: min(1320px, 100%);
  min-height: calc(100vh - 28px);
  grid-template-columns: minmax(0, 1fr);
  margin: 0 auto;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.title-ad-layout {
  display: grid;
  width: 100%;
  min-height: calc(100vh - (var(--app-shell-padding) * 2));
  grid-template-columns: minmax(0, 1fr);
  justify-content: center;
}

.title-ad-slot,
.title-mobile-ad-slot {
  display: none;
}

.title-navigation {
  position: absolute;
  z-index: 2;
  top: clamp(24px, 4.4vh, 42px);
  right: clamp(18px, 3vw, 38px);
  left: clamp(18px, 3vw, 38px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.title-language-control,
.title-gallery-button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  gap: 8px;
  border: 3px solid var(--brown);
  border-radius: 13px;
  background: rgba(255, 248, 234, 0.94);
  box-shadow: 0 4px 0 rgba(43, 33, 28, 0.28);
}

.title-language-control {
  gap: 5px;
  padding: 0 6px 0 8px;
}

.title-language-control select {
  width: auto;
  min-height: 34px;
  padding: 4px 16px 4px 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--brown);
  font-size: 0.9rem;
  outline: none;
}

.title-navigation-icon {
  display: inline-grid;
  width: 22px;
  height: 22px;
  place-items: center;
  color: var(--brown);
}

.title-navigation-icon svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.4;
}

.title-gallery-button {
  justify-content: center;
  padding: 8px 12px;
  color: var(--brown);
  font-weight: 900;
  white-space: nowrap;
}

.title-gallery-button:hover {
  transform: translateY(2px);
  box-shadow: 0 2px 0 rgba(43, 33, 28, 0.28);
}

.title-gallery-button:active {
  transform: translateY(4px);
  box-shadow: none;
}

.title-content {
  display: grid;
  width: 100%;
  height: min(760px, calc(100vh - 28px));
  min-height: 650px;
  min-width: 0;
  justify-items: center;
  gap: 64px;
  padding: clamp(20px, 3vh, 30px) 50px;
  transform: translateY(-50px);
}

.title-layout-tuner {
  position: fixed;
  z-index: 120;
  top: 88px;
  right: 14px;
  width: min(316px, calc(100vw - 28px));
  max-height: calc(100dvh - 104px);
  overflow: auto;
  border: 3px solid var(--brown);
  border-radius: 12px;
  background: rgba(255, 248, 234, 0.97);
  box-shadow: var(--shadow-hard);
  color: var(--brown);
  font-size: 0.78rem;
  font-weight: 900;
}

@media (max-width: 1100px) {
  .title-layout-tuner {
    position: relative;
    top: auto;
    right: auto;
    width: min(520px, calc(100% - 24px));
    max-height: none;
    margin: 14px auto 28px;
  }
}
.title-layout-tuner > summary {
  padding: 10px 12px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.title-layout-tuner > summary::-webkit-details-marker {
  display: none;
}

.title-layout-tuner > summary::after {
  float: right;
  content: "-";
  font-size: 1.1rem;
}

.title-layout-tuner:not([open]) > summary::after {
  content: "+";
}

.title-layout-tuner-body {
  display: grid;
  gap: 10px;
  padding: 0 10px 10px;
  border-top: 2px solid rgba(74, 50, 37, 0.2);
}

.title-layout-tuner-body > p {
  margin: 0;
  color: var(--muted);
  font-size: 0.68rem;
}

.title-layout-tuner-controls {
  display: grid;
  gap: 7px;
}

.title-layout-tuner-row {
  display: grid;
  grid-template-columns: 1fr minmax(92px, 1.25fr) 54px;
  align-items: center;
  gap: 7px;
}

.title-layout-tuner-row span {
  min-width: 0;
  line-height: 1.1;
}

.title-layout-tuner-row input[type="range"] {
  width: 100%;
  min-height: auto;
  margin: 0;
  padding: 0;
  accent-color: var(--orange);
}

.title-layout-tuner-row output {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.title-layout-tuner-values {
  width: 100%;
  min-height: 126px;
  resize: vertical;
  padding: 8px;
  border: 2px solid var(--brown);
  border-radius: 8px;
  background: #fffefa;
  color: var(--ink);
  font: 700 0.68rem/1.35 monospace;
}

.title-layout-tuner-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.title-layout-tuner-actions button {
  min-height: 34px;
  padding: 6px;
  border: 2px solid var(--brown);
  border-radius: 8px;
  background: var(--panel);
  color: var(--brown);
  font: inherit;
  font-weight: 900;
}

.title-layout-tuner-actions button:last-child {
  background: var(--orange);
  color: #fff;
}
.title-footer {
  position: absolute;
  z-index: 2;
  right: clamp(18px, 3vw, 38px);
  bottom: clamp(18px, 3vh, 30px);
  left: clamp(18px, 3vw, 38px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: rgba(255, 248, 234, 0.95);
  font-size: 0.78rem;
  font-weight: 900;
  text-shadow: 0 2px 0 rgba(74, 50, 37, 0.5);
}

.title-footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.title-footer-link {
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-decoration: none;
}

.title-footer-link:hover,
.title-footer-link:focus-visible {
  color: #fff;
  text-decoration: underline;
}

.title-version {
  order: -1;
  color: rgba(255, 248, 234, 0.78);
  font-size: 0.7rem;
  font-weight: 900;
  text-shadow: 0 2px 0 rgba(74, 50, 37, 0.5);
}

.title-logo {
  display: grid;
  justify-items: center;
  text-align: center;
}

.app-logo {
  display: block;
  max-width: 100%;
  object-fit: contain;
}

.title-logo-image {
  width: min(496px, 76vw);
  height: auto;
}

.title-name {
  margin: 0;
  color: var(--cream);
  font-size: 5.4rem;
  line-height: 0.92;
  text-shadow: 0 4px 0 var(--brown), 0 9px 0 rgba(43, 33, 28, 0.22);
  -webkit-text-stroke: 3px var(--brown);
}

.title-subtitle {
  margin: 2px 0 0;
  color: var(--cream);
  font-size: 1.3rem;
  transform: translateY(-12px);
  font-weight: 900;
  text-shadow: 0 2px 0 rgba(74, 50, 37, 0.58);
}

.player-card {
  --title-menu-row-width: 550px;
  --title-control-height: 55px;
  display: grid;
  width: min(var(--title-menu-row-width), 100%);
  gap: 3px;
  padding: 0;
  transform: translateY(-12px);
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 12px;
}

.field span,
.mini-label {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 900;
}

.title-field {
  margin: 0;
}

.title-screen .field span {
  color: var(--cream);
  text-shadow: 0 2px 0 rgba(74, 50, 37, 0.55);
}

input,
select {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 3px solid var(--brown);
  border-radius: 12px;
  background: #fffefa;
  color: var(--ink);
  font-weight: 900;
}

.name-input,
.room-input {
  min-height: 50px;
}

.title-screen .name-input {
  width: min(var(--title-menu-row-width), 100%);
  height: var(--title-control-height);
  min-height: var(--title-control-height);
  max-height: var(--title-control-height);
  padding: 0 8px;
  font-size: 1rem;
  line-height: 1;
  justify-self: center;
}

.menu-grid {
  display: grid;
  gap: 22px;
}

.menu-row {
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 40px;
}

.menu-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: calc((100% - 40px) / 2);
  min-height: var(--title-control-height);
  gap: 5px;
  padding: 14px 35px;
  border: 3px solid var(--brown);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: 0 5px 0 rgba(43, 33, 28, 0.28);
  transition: transform 0.1s, box-shadow 0.1s;
}

.menu-btn:hover {
  transform: translateY(2px);
  box-shadow: 0 3px 0 rgba(43, 33, 28, 0.28);
}

.menu-btn:active {
  transform: translateY(5px);
  box-shadow: none;
}

.menu-btn-primary {
  background: var(--orange);
  color: #fff;
}

.menu-btn-primary .icon-circle {
  color: var(--orange);
}

.icon-circle {
  display: grid;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  place-items: center;
  border: 2px solid var(--brown);
  border-radius: 50%;
  background: var(--icon-color);
  color: #fff;
}

.icon-circle svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.4;
}

.btn-label {
  color: var(--brown);
  font-size: 1.27rem;
  font-weight: 900;
  white-space: nowrap;
}

.room-join {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 118px;
  gap: 10px;
}

.primary,
.secondary,
.ghost,
.danger,
.icon-button {
  min-height: 42px;
  padding: 10px 14px;
  border: 3px solid var(--brown);
  border-radius: 12px;
  font-weight: 900;
  box-shadow: 0 4px 0 rgba(74, 50, 37, 0.28);
}

.primary {
  background: var(--teal);
  color: #fff;
}

.secondary,
.title-join {
  background: var(--orange);
  color: #fff;
}

.ghost {
  background: var(--panel);
  color: var(--brown);
}

.danger,
.danger-action {
  background: #fff1e8;
  color: #a13a2d;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  border: 4px solid var(--brown);
  border-radius: 18px;
  background: rgba(255, 248, 234, 0.94);
  box-shadow: var(--shadow-hard);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.topbar-logo-image {
  width: 124px;
  height: 54px;
  object-position: left center;
}

.brand .mark {
  width: 42px;
  height: 42px;
  font-size: 0.82rem;
}

.brand-title {
  font-size: 1.06rem;
  font-weight: 900;
}

.brand-sub {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.room-code,
.timer {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border: 3px solid var(--brown);
  border-radius: 12px;
  font-weight: 900;
}

.room-code {
  background: #e5f4f1;
  color: #166f6b;
}

.timer {
  min-width: 90px;
  background: var(--brown);
  color: #fff;
  font-variant-numeric: tabular-nums;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
  margin-top: 16px;
}

.stage-wrap,
.panel {
  border: 4px solid var(--brown);
  border-radius: 20px;
  background: rgba(255, 248, 234, 0.94);
  box-shadow: var(--shadow-hard), var(--shadow-soft);
}

.stage-wrap {
  min-width: 0;
  padding: 16px;
}

.lobby-stage {
  min-height: 360px;
}

.panel {
  padding: 16px;
}

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

.crafting-screen,
.works-screen {
  width: min(var(--layout-content-max-width), 100%);
  margin: 0 auto;
  overflow: hidden;
  padding: var(--layout-content-padding);
}

.crafting-screen {
  display: flex;
  height: min(var(--layout-crafting-max-height), calc(100vh - var(--layout-viewport-edge-gap)));
  min-height: 650px;
  flex-direction: column;
  gap: var(--layout-section-gap);
}

.crafting-top-bar {
  display: grid;
  height: var(--layout-header-height);
  flex: 0 0 auto;
  grid-template-columns: var(--layout-side-column-width) minmax(360px, 1fr) var(--layout-side-column-width);
  align-items: center;
  gap: var(--layout-header-gap);
}

.mini-logo-group {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--layout-side-column-width);
  min-width: 0;
}

.mini-logo-image {
  width: var(--layout-logo-width);
  height: var(--layout-logo-height);
  object-position: center;
}

.mini-clay-blob {
  display: flex;
  width: 66px;
  height: 42px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 3px solid var(--brown);
  border-radius: 22px 14px 16px 24px;
  background: var(--cream);
  box-shadow: inset -7px -8px 0 rgba(74, 50, 37, 0.08);
}

.mini-clay-blob .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--brown);
}

.mini-logo-text {
  color: var(--cream);
  font-family: "Hiragino Maru Gothic ProN", "Yu Gothic", "Meiryo", sans-serif;
  font-size: 22px;
  text-shadow: 0 3px 0 var(--brown), 0 6px 0 rgba(43, 33, 28, 0.18);
  -webkit-text-stroke: 2px var(--brown);
}

.speech-bubble {
  position: relative;
  display: flex;
  width: 100%;
  min-width: 0;
  max-width: var(--layout-title-max-width);
  min-height: 58px;
  align-items: center;
  justify-content: center;
  justify-self: center;
  margin: 0;
  overflow: hidden;
  padding: 10px 76px;
  border: 4px solid var(--brown);
  border-radius: 999px;
  background: var(--panel);
  color: var(--brown);
  font-size: 20px;
  font-weight: 900;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
  box-shadow: 0 4px 0 rgba(74, 50, 37, 0.2);
}

.prompt-chip {
  position: absolute;
  left: 12px;
  display: inline-flex;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--orange);
  color: #fff;
  font-size: 12px;
}

.prompt-text {
  overflow: hidden;
  max-width: 100%;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-right-group {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-self: end;
  margin-left: 0;
}

.craft-badge {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  padding: 7px 14px;
  border: 3px solid var(--brown);
  border-radius: 14px;
  color: #fff;
  font-size: 14px;
  font-weight: 900;
  box-shadow: 0 4px 0 rgba(74, 50, 37, 0.24);
}

.badge-brush {
  min-width: 132px;
  background: var(--blue);
}

.badge-timer {
  min-width: 132px;
  min-height: 58px;
  flex-direction: column;
  gap: 1px;
  background: var(--orange);
  font-size: 24px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.badge-timer::before {
  content: attr(data-label);
  font-size: 10px;
  line-height: 1;
}

.main-workspace {
  display: grid;
  grid-template-columns: var(--layout-side-column-width) minmax(0, 1fr);
  flex: 1;
  min-height: 0;
  gap: var(--layout-workspace-gap);
}

.workspace-toolbar {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 12px;
  overflow: auto;
  padding: 14px;
  border: var(--layout-panel-border-width) solid var(--brown);
  border-radius: var(--layout-panel-radius);
  background: var(--cream);
  box-shadow: var(--shadow-hard);
}

.command-toolbar {
  gap: 8px;
  overflow: hidden;
  padding: var(--layout-toolbar-padding);
}

.command-toolbar .toolbar-section {
  gap: 6px;
}

.command-toolbar .section-label {
  font-size: 12px;
  line-height: 1;
}

.command-toolbar .shape-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.command-toolbar .shape-btn {
  min-height: 44px;
  padding: 4px;
}

.command-toolbar .selected-info,
.command-toolbar .brush-readout {
  min-height: 30px;
  padding: 4px 8px;
  font-size: 12px;
  line-height: 14px;
}

.command-toolbar .action-btn,
.command-toolbar .wide-action {
  min-height: 38px;
  padding: 5px 8px;
}

.command-toolbar .color-section {
  gap: 7px;
}

.palette-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.palette-add-button {
  display: grid;
  width: 22px;
  height: 22px;
  min-height: 0;
  place-items: center;
  padding: 0;
  border: 2px solid var(--brown);
  border-radius: 5px;
  color: var(--brown);
  background: #fffefa;
  box-shadow: 0 2px 0 rgba(74, 50, 37, 0.18);
}

.palette-add-button:hover {
  border-color: var(--orange);
  color: var(--orange);
  background: #fff0d8;
}

.palette-add-button svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 3;
}

.hex-color-input {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  color: var(--brown);
  font-size: 11px;
  font-weight: 900;
}

.hex-color-input input {
  width: 100%;
  min-width: 0;
  min-height: 30px;
  padding: 3px 7px;
  border: 2px solid var(--brown);
  border-radius: 6px;
  color: var(--brown);
  font: inherit;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  text-transform: uppercase;
  background: #fffefa;
  box-shadow: none;
}

.color-picker-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 20px;
  gap: 8px;
  height: 92px;
}

.color-field {
  position: relative;
  min-width: 0;
  overflow: hidden;
  cursor: crosshair;
  border: 2px solid var(--brown);
  border-radius: 5px;
  background:
    linear-gradient(to top, #000, transparent),
    linear-gradient(to right, #fff, hsl(var(--hue, 20) 100% 50%));
  touch-action: none;
}

.color-field-cursor {
  position: absolute;
  top: var(--brightness, 0%);
  left: var(--saturation, 100%);
  width: 13px;
  height: 13px;
  transform: translate(-50%, -50%);
  border: 2px solid #fff;
  border-radius: 50%;
  pointer-events: none;
  box-shadow: 0 0 0 2px var(--brown), 0 1px 2px rgba(43, 33, 28, 0.38);
}

.color-hue-control {
  display: flex;
  min-width: 0;
  overflow: hidden;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--brown);
  border-radius: 999px;
  background: linear-gradient(to top, #f00, #f0f, #00f, #0ff, #0f0, #ff0, #f00);
}

.color-hue-control input {
  width: 16px;
  height: 86px;
  min-height: 0;
  margin: 0;
  padding: 0;
  appearance: slider-vertical;
  -webkit-appearance: slider-vertical;
  accent-color: #fff;
  cursor: ns-resize;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.command-toolbar .palette-swatches {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.command-toolbar .swatch {
  min-height: 32px;
  border-radius: 4px;
  box-shadow: 0 0 0 2px rgba(74, 50, 37, 0.38), inset -4px -5px 8px rgba(43, 33, 28, 0.18);
}

.command-toolbar .palette-add-button {
  width: 100%;
  height: auto;
  min-height: 32px;
  aspect-ratio: 1;
  border-radius: 4px;
  box-shadow: 0 0 0 2px rgba(74, 50, 37, 0.38), inset -3px -4px 7px rgba(43, 33, 28, 0.1);
}

.command-toolbar .palette-add-button svg {
  width: 18px;
  height: 18px;
}

.color-rgb-controls {
  display: grid;
  gap: 4px;
}

.color-rgb-controls label {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr) 28px;
  align-items: center;
  gap: 7px;
  color: var(--brown);
  font-size: 12px;
  font-weight: 900;
}

.color-rgb-controls input {
  width: 100%;
  min-height: 12px;
  padding: 0;
  border: 0;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  box-shadow: none;
}

.color-rgb-controls label:nth-child(1) input {
  --channel-color: #ef5344;
}

.color-rgb-controls label:nth-child(2) input {
  --channel-color: #4fae54;
}

.color-rgb-controls label:nth-child(3) input {
  --channel-color: #438fda;
}

.color-rgb-controls input::-webkit-slider-runnable-track {
  height: 6px;
  border: 1px solid rgba(74, 50, 37, 0.2);
  border-radius: 999px;
  background: linear-gradient(to right, #fffefa, var(--channel-color));
}

.color-rgb-controls input::-webkit-slider-thumb {
  width: 10px;
  height: 10px;
  margin-top: -3px;
  appearance: none;
  -webkit-appearance: none;
  border: 2px solid #fffefa;
  border-radius: 50%;
  background: var(--channel-color);
  box-shadow: 0 0 0 1px rgba(74, 50, 37, 0.46);
}

.color-rgb-controls input::-moz-range-track {
  height: 6px;
  border: 1px solid rgba(74, 50, 37, 0.2);
  border-radius: 999px;
  background: linear-gradient(to right, #fffefa, var(--channel-color));
}

.color-rgb-controls input::-moz-range-thumb {
  width: 8px;
  height: 8px;
  border: 2px solid #fffefa;
  border-radius: 50%;
  background: var(--channel-color);
  box-shadow: 0 0 0 1px rgba(74, 50, 37, 0.46);
}

.color-rgb-controls output {
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.workspace-toolbar-title {
  display: grid;
  gap: 2px;
  padding-bottom: 8px;
  border-bottom: 2px solid rgba(74, 50, 37, 0.28);
  color: var(--brown);
}

.workspace-toolbar-title span {
  font-size: 15px;
  font-weight: 900;
}

.workspace-toolbar-title small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
}

.color-toolbar {
  background: #e8f6f4;
}

.color-toolbar .workspace-toolbar-title {
  color: #166f6b;
}

.color-toolbar .workspace-toolbar-title small {
  color: #287d78;
}

.toolbar-section {
  display: grid;
  gap: 10px;
}

.section-label {
  color: var(--brown);
  font-size: 13px;
  font-weight: 900;
}

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

.tool-btn,
.action-btn,
.wide-action {
  border: 3px solid var(--brown);
  background: var(--panel);
  color: var(--brown);
  font-weight: 900;
  box-shadow: 0 4px 0 rgba(74, 50, 37, 0.22);
  transition: transform 0.1s, box-shadow 0.1s, background 0.15s;
}

.tool-btn:hover,
.action-btn:hover,
.wide-action:hover,
.complete-btn:hover {
  transform: translateY(2px);
  box-shadow: 0 2px 0 rgba(74, 50, 37, 0.22);
}

.tool-btn:active,
.action-btn:active,
.wide-action:active,
.complete-btn:active {
  transform: translateY(5px);
  box-shadow: none;
}

.tool-btn {
  display: grid;
  min-height: 70px;
  place-items: center;
  gap: 4px;
  padding: 8px;
  border-radius: 16px;
}

.shape-btn {
  min-height: 50px;
  padding: 6px;
}

.tool-btn:nth-child(1) {
  background: #fff0d8;
}

.tool-btn:nth-child(2) {
  background: #e8f6f4;
}

.tool-btn:nth-child(3) {
  background: #fff6cf;
}

.tool-btn:nth-child(4) {
  background: #eee7fa;
}

.tool-btn svg,
.action-btn svg,
.wide-action svg,
.instruction-panel svg,
.complete-btn svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.6;
}

.selected-info,
.brush-readout {
  min-height: 36px;
  padding: 8px 10px;
  border: 3px solid rgba(74, 50, 37, 0.24);
  border-radius: 12px;
  background: #fffefa;
  color: var(--brown);
  font-size: 13px;
  font-weight: 900;
}

.brush-readout {
  background: #e8f6f4;
  color: #166f6b;
}

.range-line {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
}

.range-line span {
  color: var(--brown);
  font-size: 12px;
  font-weight: 900;
}

.range-line input {
  min-height: 18px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  accent-color: var(--orange);
  background: transparent;
  box-shadow: none;
}

.color-picker-row {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.color-picker-row input {
  width: 54px;
  height: 42px;
  min-height: 42px;
  padding: 3px;
}

.palette-swatches {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

.color-toolbar .palette-swatches {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.swatch {
  aspect-ratio: 1;
  min-height: 30px;
  border: 3px solid var(--cream);
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(74, 50, 37, 0.38), inset -5px -6px 10px rgba(43, 33, 28, 0.18);
  transition: transform 0.1s, box-shadow 0.1s;
}

.swatch.active,
.swatch:hover {
  transform: scale(1.08);
  box-shadow: 0 0 0 3px var(--brown), inset -5px -6px 10px rgba(43, 33, 28, 0.18);
}

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

.action-btn,
.wide-action {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 14px;
  font-size: 13px;
}

.wide-action {
  width: 100%;
}

.viewport-container {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  border: var(--layout-panel-border-width) solid var(--brown);
  border-radius: var(--layout-panel-radius);
  background: var(--cream);
  box-shadow: var(--shadow-hard);
}

.mobile-builder-ad-slot {
  display: none;
}

.sculpting-canvas {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 100%;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.sculpting-canvas canvas,
.preview-frame canvas {
  background: var(--cream-2);
}

.viewport-hud {
  position: absolute;
  top: 16px;
  right: 16px;
  display: flex;
  gap: 8px;
  pointer-events: none;
}

.viewport-control-dock {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 5;
  display: grid;
  width: min(220px, calc(100% - 32px));
  grid-template-columns: minmax(0, 1fr);
  gap: 5px;
  padding: 6px;
  transform: none;
  border: 4px solid var(--brown);
  border-radius: 16px;
  background: rgba(255, 248, 234, 0.95);
  box-shadow: 0 4px 0 rgba(74, 50, 37, 0.22);
}

.viewport-slider {
  display: grid;
  min-width: 0;
  grid-template-columns: auto minmax(0, 1fr) 68px;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 4px 7px;
  border: 2px solid rgba(74, 50, 37, 0.22);
  border-radius: 10px;
  color: var(--brown);
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.viewport-slider span {
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.viewport-slider > input[type="range"] {
  width: 100%;
  min-width: 0;
  min-height: 18px;
  padding: 0;
  border: 0;
  accent-color: var(--orange);
  background: transparent;
  box-shadow: none;
}

.viewport-slider-value {
  display: grid;
  grid-template-columns: minmax(0, 48px) auto;
  align-items: center;
  gap: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.viewport-slider-value input {
  width: 48px;
  min-width: 0;
  min-height: 18px;
  padding: 0;
  border: 0;
  color: var(--brown);
  font: inherit;
  text-align: right;
  background: transparent;
  box-shadow: none;
}

.viewport-slider-value input[type="number"] {
  appearance: textfield;
  -moz-appearance: textfield;
}

.viewport-slider-value input[type="number"]::-webkit-inner-spin-button,
.viewport-slider-value input[type="number"]::-webkit-outer-spin-button {
  margin: 0;
  -webkit-appearance: none;
}

.viewport-slider-value span {
  color: var(--muted);
  font-size: 11px;
}

.viewport-control-dock.is-sculpting .viewport-slider-brush {
  border-color: var(--orange);
  background: #fff0d8;
  box-shadow: inset 0 0 0 1px rgba(255, 123, 48, 0.2);
}

.hud-pill {
  padding: 7px 10px;
  border: 3px solid var(--brown);
  border-radius: 999px;
  background: rgba(255, 248, 234, 0.92);
  color: var(--brown);
  font-size: 12px;
  font-weight: 900;
  box-shadow: 0 3px 0 rgba(74, 50, 37, 0.2);
}

.canvas-message {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 4;
  max-width: min(320px, calc(100% - 24px));
  padding: 10px 14px;
  transform: translate(-50%, -50%);
  border: 3px solid var(--brown);
  border-radius: 14px;
  background: rgba(255, 248, 234, 0.96);
  color: var(--brown);
  font-weight: 900;
  text-align: center;
  box-shadow: 0 4px 0 rgba(74, 50, 37, 0.2);
  pointer-events: none;
}

.bottom-bar {
  display: grid;
  min-height: var(--layout-footer-min-height);
  flex: 0 0 auto;
  grid-template-columns: var(--layout-footer-action-width) minmax(0, 1fr) var(--layout-footer-action-width);
  align-items: stretch;
  gap: var(--layout-workspace-gap);
}

.builder-back {
  width: 100%;
  min-width: 0;
  min-height: var(--layout-footer-action-min-height);
}

.builder-footer-spacer {
  min-width: 0;
}

.instruction-panel {
  display: flex;
  min-width: 0;
  flex: 1;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  padding: var(--layout-instruction-padding);
  border: 4px solid var(--brown);
  border-radius: 20px;
  background: var(--panel);
  box-shadow: 0 4px 0 rgba(74, 50, 37, 0.22);
  text-align: left;
}

.instruction-panel span {
  color: var(--brown);
  font-size: 13px;
  font-weight: 900;
  line-height: 1.35;
  text-align: left;
  white-space: normal;
}

.complete-btn {
  display: inline-flex;
  width: 100%;
  min-width: 0;
  min-height: var(--layout-footer-action-min-height);
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 32px;
  border: 5px solid var(--brown);
  border-radius: 24px;
  background: var(--orange);
  color: #fff;
  font-size: 21px;
  font-weight: 900;
  box-shadow: var(--shadow-hard);
}

.canvas-frame {
  position: relative;
  display: grid;
  min-height: min(66vh, 680px);
  overflow: hidden;
  border: 4px solid var(--brown);
  border-radius: 20px;
  background: var(--cream-2);
}

.preview-frame {
  min-height: min(62vh, 620px);
}

.canvas-hint {
  position: absolute;
  left: 12px;
  bottom: 12px;
  max-width: calc(100% - 24px);
  padding: 8px 11px;
  border: 3px solid var(--brown);
  border-radius: 12px;
  background: rgba(255, 248, 234, 0.92);
  color: var(--brown);
  font-size: 0.78rem;
  font-weight: 900;
}

.answer-form {
  display: grid;
  gap: 10px;
}

.prompt-box,
.reveal-answer {
  padding: 14px;
  border: 3px solid var(--brown);
  border-radius: 16px;
  background: #fff6d6;
}

.correct-word {
  font-size: 2rem;
  line-height: 1.05;
  font-weight: 900;
}

.players {
  display: grid;
  gap: 8px;
}

.player-row,
.answer-row,
.score-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 9px 10px;
  border: 3px solid rgba(74, 50, 37, 0.2);
  border-radius: 14px;
  background: #fffefa;
}

.player-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 900;
}

.avatar {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 3px solid var(--brown);
  border-radius: 50%;
  background: #e8f6f4;
  color: #166f6b;
  font-size: 11px;
  font-weight: 900;
}

.tag {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  padding: 4px 8px;
  border: 2px solid rgba(74, 50, 37, 0.16);
  border-radius: 999px;
  background: #f2ead9;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
}

.tag.good {
  background: #e7f6de;
  color: #427938;
}

.tag.bad {
  background: #fff0ec;
  color: #a13a2d;
}

.tag.host {
  background: #e5f4f1;
  color: #166f6b;
}

.scoreboard {
  display: grid;
  gap: 8px;
}

.score-row {
  grid-template-columns: 42px minmax(0, 1fr) auto;
}

.rank {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 3px solid var(--brown);
  border-radius: 50%;
  background: var(--gold);
  color: var(--brown);
  font-weight: 900;
}

.score-detail {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.big-score {
  font-size: 1.25rem;
  font-weight: 900;
}

.works-panel {
  overflow: auto;
  max-height: calc(100vh - 118px);
}

.works-screen {
  display: grid;
  min-height: calc(100vh - 28px);
  gap: 16px;
  align-content: start;
}

.works-header {
  display: flex;
  align-items: center;
  gap: 16px;
}

.works-header .speech-bubble {
  flex: 1;
}

.library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 320px));
  gap: 14px;
  align-items: start;
}

.library-card {
  border: 4px solid var(--brown);
  border-radius: 18px;
  box-shadow: var(--shadow-hard);
}

.library-meta {
  display: grid;
  gap: 2px;
}

.library-meta strong {
  overflow: hidden;
  color: var(--brown);
  font-size: 1rem;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.library-meta span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.empty-works {
  padding: 22px;
  border: 4px solid var(--brown);
  border-radius: 18px;
  background: var(--panel);
  color: var(--brown);
  font-weight: 900;
  text-align: center;
  box-shadow: var(--shadow-hard);
}

.gallery-screen {
  display: grid;
  width: min(var(--layout-content-max-width), 100%);
  min-height: calc(100vh - 28px);
  grid-template-rows: var(--layout-header-height) minmax(0, 1fr) var(--layout-footer-min-height);
  gap: var(--layout-section-gap);
  margin: 0 auto;
  padding: var(--layout-content-padding);
}

.gallery-loading {
  place-items: center;
  color: var(--cream);
  font-weight: 900;
}

.gallery-header {
  display: grid;
  min-height: var(--layout-header-height);
  grid-template-columns: var(--layout-side-column-width) minmax(0, 1fr) var(--layout-side-column-width);
  align-items: center;
  gap: var(--layout-header-gap);
}

.gallery-logo {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: center;
}

.gallery-logo-image {
  width: min(208px, 100%);
  height: 54px;
  object-position: left center;
}

.gallery-heading {
  display: grid;
  min-width: min(360px, 42vw);
  place-content: center;
  justify-self: center;
  padding: 9px 28px 8px;
  border: 4px solid var(--brown);
  border-radius: 24px;
  background: rgba(255, 248, 234, 0.96);
  box-shadow: 0 5px 0 rgba(43, 33, 28, 0.28);
  color: var(--brown);
  text-align: center;
}

.gallery-heading strong {
  font-size: clamp(1.3rem, 2.3vw, 2rem);
  line-height: 1.05;
  white-space: nowrap;
}

.gallery-heading small {
  margin-top: 4px;
  font-size: 0.62rem;
  font-weight: 900;
}

.gallery-sort-control {
  justify-self: end;
  display: grid;
  min-width: 132px;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  border: 3px solid var(--brown);
  border-radius: 13px;
  background: rgba(255, 254, 250, 0.96);
  box-shadow: 0 4px 0 rgba(43, 33, 28, 0.26);
  color: var(--brown);
  font-size: 0.7rem;
  font-weight: 900;
}

.gallery-sort-control select {
  min-height: 28px;
  padding: 0 14px 0 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  outline: 0;
}

.gallery-grid {
  display: grid;
  min-height: 0;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-content: start;
  gap: 18px;
}

.gallery-card {
  position: relative;
  display: grid;
  min-width: 0;
  overflow: hidden;
  border: 4px solid var(--brown);
  border-radius: 20px;
  background: rgba(255, 254, 250, 0.98);
  box-shadow: 0 7px 0 rgba(43, 33, 28, 0.3);
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.gallery-card:hover,
.gallery-card:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 9px 0 rgba(43, 33, 28, 0.32);
  outline: none;
}

.gallery-card-thumbnail {
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  margin: 9px 9px 0;
  border: 3px solid var(--brown);
  border-radius: 12px;
  background: var(--cream-2);
}

.gallery-card-thumbnail img,
.gallery-card-thumbnail canvas {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.gallery-cloud-thumbnail {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  padding: 12px;
  color: var(--brown);
  background: #e7e4dd;
  font-size: .78rem;
  font-weight: 900;
  text-align: center;
}

.gallery-favorite-button {
  position: absolute;
  top: 8px;
  right: 8px;
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  padding: 0;
  border: 3px solid var(--brown);
  border-radius: 50%;
  background: rgba(255, 254, 250, 0.96);
  box-shadow: 0 3px 0 rgba(43, 33, 28, 0.28);
  color: var(--brown);
  font-size: 1.45rem;
  line-height: 1;
}

.gallery-favorite-button.is-favorite {
  background: var(--orange);
  color: #fff;
}

.gallery-card-meta {
  display: flex;
  min-width: 0;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 11px 11px;
  color: var(--brown);
}

.gallery-card-meta > div {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.gallery-card-meta strong {
  overflow: hidden;
  font-size: 1rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gallery-card-meta small,
.gallery-card-meta time {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
  white-space: nowrap;
}

.gallery-empty {
  display: grid;
  min-height: 280px;
  grid-column: 1 / -1;
  place-content: center;
  gap: 8px;
  border: 3px dashed rgba(74, 50, 37, 0.72);
  border-radius: 18px;
  background: rgba(255, 248, 234, 0.72);
  color: var(--brown);
  text-align: center;
}

.gallery-empty strong {
  font-size: 1.15rem;
}

.gallery-empty span {
  font-size: 0.8rem;
  font-weight: 900;
}

.gallery-footer {
  display: grid;
  min-height: var(--layout-footer-min-height);
  grid-template-columns: var(--layout-footer-action-width) minmax(0, 1fr) var(--layout-footer-action-width);
  align-items: stretch;
  gap: var(--layout-workspace-gap);
}

.gallery-back-button,
.gallery-pagination button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 3px solid var(--brown);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: 0 4px 0 rgba(43, 33, 28, 0.28);
  color: var(--brown);
  font-weight: 900;
}

.gallery-back-button {
  width: 100%;
  min-height: var(--layout-footer-action-min-height);
  justify-self: stretch;
  padding: 7px 14px;
}

.gallery-pagination {
  display: flex;
  align-items: center;
  justify-self: center;
  gap: 12px;
}

.gallery-pagination button {
  width: 42px;
  padding: 0;
  font-size: 1.1rem;
}

.gallery-pagination button:disabled {
  cursor: default;
  opacity: 0.42;
  box-shadow: none;
}

.gallery-pagination strong,
.gallery-count {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 8px 14px;
  border-radius: 11px;
  background: rgba(74, 50, 37, 0.32);
  color: #fff;
  font-size: 0.76rem;
  font-weight: 900;
}

.gallery-count {
  justify-self: center;
}

.works-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
}

.work-card {
  position: relative;
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 3px solid rgba(74, 50, 37, 0.24);
  border-radius: 16px;
  background: #fffefa;
}

.thumb {
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border: 3px solid var(--brown);
  border-radius: 12px;
  background: var(--cream-2);
}

.library-thumb-image {
  display: block;
  height: auto;
  object-fit: contain;
}

.library-thumb-placeholder {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 1.4rem;
  font-weight: 900;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 20;
  max-width: min(520px, calc(100vw - 28px));
  padding: 12px 16px;
  transform: translateX(-50%) translateY(80px);
  border: 3px solid var(--brown);
  border-radius: 14px;
  background: var(--brown);
  color: #fff;
  font-weight: 900;
  opacity: 0;
  pointer-events: none;
  transition: 180ms ease;
  box-shadow: var(--shadow-soft);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.dialog-root {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  padding: 24px;
  place-items: center;
  background: rgba(43, 33, 28, 0.42);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}

.dialog-root.is-open {
  opacity: 1;
  pointer-events: auto;
}

.dialog-card {
  width: min(680px, 100%);
  padding: 28px;
  border: 4px solid var(--brown);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: var(--shadow-hard), var(--shadow-soft);
  transform: translateY(10px);
  transition: transform 160ms ease;
}

.dialog-root.is-open .dialog-card {
  transform: translateY(0);
}

.dialog-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.dialog-mark {
  display: grid;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  place-items: center;
  border: 3px solid var(--brown);
  border-radius: 50%;
  background: var(--gold);
  color: var(--brown);
  font-size: 1.1rem;
  font-weight: 900;
}

.dialog-title-row h2 {
  margin: 0;
  font-size: 1.35rem;
}

.dialog-message {
  margin: 16px 0 22px;
  color: var(--muted);
  font-weight: 800;
  line-height: 1.6;
}

.dialog-actions {
  display: flex;
  flex-wrap: nowrap;
  justify-content: flex-end;
  gap: 10px;
}

.dialog-action {
  min-width: 0;
  min-height: 54px;
  flex: 1 1 0;
  padding: 10px 16px;
  border: 3px solid var(--brown);
  border-radius: 11px;
  color: var(--brown);
  font-weight: 900;
  line-height: 1.25;
  box-shadow: 0 4px 0 rgba(43, 33, 28, 0.28);
}

.dialog-action:hover {
  transform: translateY(1px);
  box-shadow: 0 3px 0 rgba(43, 33, 28, 0.28);
}

.dialog-action:active {
  transform: translateY(4px);
  box-shadow: none;
}

.dialog-action-secondary {
  background: #fffdf7;
}

.dialog-action-primary {
  background: var(--orange);
  color: #fff;
}

.dialog-action-danger {
  background: #d64b43;
  color: #fff;
}

.reference-screen {
  display: grid;
  width: min(var(--layout-content-max-width), 100%);
  min-height: calc(100vh - 28px);
  grid-template-rows: var(--layout-header-height) minmax(0, 1fr) var(--layout-footer-min-height);
  gap: var(--layout-section-gap);
  margin: 0 auto;
  padding: var(--layout-content-padding);
}

.reference-header {
  display: grid;
  min-height: var(--layout-header-height);
  grid-template-columns: var(--layout-side-column-width) minmax(0, 1fr) var(--layout-side-column-width);
  align-items: center;
  gap: var(--layout-header-gap);
}

.reference-brand {
  display: block;
  width: 164px;
  justify-self: center;
  padding: 0;
  background: transparent;
}

.reference-logo-image {
  width: 164px;
  height: 88px;
  object-position: left center;
}

.reference-brand b,
.reference-brand small,
.reference-title strong,
.reference-title small,
.reference-footer small,
.reference-action-button small,
.mode-choice small,
.lobby-reference-card small,
.quick-match-card p,
.settings-reference-panel small,
.work-info-reference-card small {
  display: block;
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0;
}

.reference-brand b {
  display: block;
  font-size: clamp(1.2rem, 2vw, 1.75rem);
  line-height: 1;
}

.reference-brand small {
  margin-top: 4px;
  color: var(--cream);
}

.reference-blob {
  position: relative;
  display: inline-flex;
  width: 80px;
  height: 54px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 4px solid var(--brown);
  border-radius: 20px;
  background: var(--panel);
  box-shadow: 0 5px 0 rgba(43, 33, 28, 0.3);
}

.reference-blob i {
  display: block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brown);
}

.reference-title {
  display: grid;
  min-width: min(360px, 42vw);
  justify-items: center;
  justify-self: center;
  padding: 9px 28px 8px;
  border: 4px solid var(--brown);
  border-radius: 24px;
  background: rgba(255, 248, 234, 0.96);
  box-shadow: 0 5px 0 rgba(43, 33, 28, 0.28);
  color: var(--brown);
  text-align: center;
}

.reference-title strong {
  font-size: clamp(1.3rem, 2.3vw, 2rem);
  line-height: 1.05;
}

.reference-title small {
  margin-top: 3px;
}

.reference-version {
  justify-self: end;
  color: var(--cream);
  font-size: 0.8rem;
  font-weight: 900;
}

.reference-main {
  display: grid;
  align-items: center;
}

.reference-footer {
  display: grid;
  min-height: var(--layout-footer-min-height);
  grid-template-columns: var(--layout-footer-action-width) minmax(0, 1fr) var(--layout-footer-action-width);
  align-items: stretch;
  gap: var(--layout-workspace-gap);
}

.reference-back,
.reference-footer-action > button,
.reference-primary,
.reference-action-button,
.reference-control-button {
  border: 4px solid var(--brown);
  color: var(--brown);
  font-weight: 900;
  box-shadow: 0 6px 0 rgba(43, 33, 28, 0.34);
}

.reference-back {
  display: inline-flex;
  width: 100%;
  min-width: 0;
  min-height: var(--layout-footer-action-min-height);
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 18px;
  background: var(--panel);
  font-size: 1rem;
}

.reference-back svg,
.reference-action-button svg,
.reference-control-button svg,
.reference-primary svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.6;
}

.reference-back small {
  display: none;
}

.reference-tip {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 10px 16px;
  border: 2px solid rgba(74, 50, 37, 0.78);
  border-radius: 12px;
  background: rgba(153, 65, 47, 0.58);
  color: var(--cream);
  font-size: 0.82rem;
  font-weight: 900;
  text-align: center;
}

.reference-footer > .reference-footer-action {
  width: 100%;
  min-width: 0;
  justify-self: stretch;
}

.reference-footer-action > button,
.reference-primary {
  display: grid;
  width: 100%;
  min-height: var(--layout-footer-action-min-height);
  place-items: center;
  padding: 8px 16px;
  border-radius: 18px;
  background: var(--orange);
  color: #fff;
  font-size: 1rem;
}

.reference-footer-action > button small,
.reference-primary small {
  margin-top: 2px;
  color: inherit;
}

.online-chip {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  padding: 9px 14px;
  border: 2px solid var(--brown);
  border-radius: 12px;
  background: rgba(153, 65, 47, 0.63);
  color: var(--cream);
  font-size: 0.78rem;
  font-weight: 900;
  white-space: nowrap;
}

.mode-select-main {
  width: min(920px, 100%);
  margin: 0 auto;
}

.mode-choice-grid,
.lobby-reference-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(28px, 4vw, 58px);
}

.mode-choice {
  display: grid;
  min-height: 350px;
  align-content: center;
  justify-items: center;
  gap: 16px;
  padding: 30px;
  border: 4px solid var(--brown);
  border-radius: 30px;
  background: rgba(255, 250, 240, 0.96);
  box-shadow: 0 9px 0 rgba(43, 33, 28, 0.38);
  color: var(--brown);
  text-align: center;
}

.mode-choice:hover,
.reference-action-button:hover,
.reference-primary:hover,
.reference-footer-action > button:hover,
.reference-back:hover,
.reference-control-button:hover {
  transform: translateY(-2px);
}

.mode-choice:active,
.reference-action-button:active,
.reference-primary:active,
.reference-footer-action > button:active,
.reference-back:active,
.reference-control-button:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 rgba(43, 33, 28, 0.34);
}

.mode-choice strong {
  font-size: clamp(1.75rem, 4vw, 2.65rem);
  line-height: 1.1;
}

.mode-choice > span:last-child {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 2px;
  padding: 7px 16px;
  border-radius: 18px;
  background: rgba(74, 50, 37, 0.08);
  font-weight: 900;
}

.mode-choice small {
  align-self: center;
  color: var(--muted);
}

.mode-icon {
  display: grid;
  width: 108px;
  height: 108px;
  place-items: center;
  border: 4px solid var(--brown);
  border-radius: 50%;
  background: var(--orange);
  color: var(--brown);
}

.mode-icon svg {
  width: 48px;
  height: 48px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.mode-choice-blue .mode-icon { background: var(--blue); }
.mode-choice-green .mode-icon { background: var(--green); }
.mode-choice-purple .mode-icon { background: var(--purple); }

.join-lobby-main,
.quick-match-main {
  width: min(780px, 100%);
  margin: 0 auto;
}

.join-room-card,
.quick-match-card,
.settings-reference-panel,
.lobby-reference-card,
.work-preview-reference-card,
.work-info-reference-card {
  border: 4px solid var(--brown);
  background: rgba(255, 250, 240, 0.97);
  box-shadow: 0 9px 0 rgba(43, 33, 28, 0.38);
}

.join-room-card {
  display: grid;
  justify-items: center;
  gap: 18px;
  padding: clamp(28px, 5vw, 50px);
  border-radius: 30px;
  text-align: center;
}

.join-room-card h1,
.quick-match-card h1 {
  margin: 0;
  color: var(--brown);
  font-size: clamp(1.35rem, 3vw, 2rem);
}

.join-room-card > p,
.join-room-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
}

.room-code-inputs,
.lobby-code-characters {
  display: flex;
  justify-content: center;
  gap: clamp(8px, 2vw, 18px);
}

.room-character,
.lobby-code-char {
  display: grid;
  width: clamp(48px, 8vw, 82px);
  height: clamp(58px, 10vw, 92px);
  place-items: center;
  padding: 0;
  border: 4px solid var(--brown);
  border-radius: 18px;
  background: #fffefa;
  color: var(--brown);
  font-size: clamp(1.9rem, 5vw, 3.5rem);
  font-weight: 900;
  text-align: center;
}

.room-character:focus {
  outline: none;
  border-color: var(--orange);
  box-shadow: 0 0 0 4px rgba(255, 123, 48, 0.26);
}

.mobile-room-code-input {
  display: none;
}

.reference-primary {
  width: min(300px, 100%);
  grid-template-columns: auto 1fr;
  gap: 8px;
}

.reference-primary-green {
  background: var(--green);
  color: var(--brown);
}

.quick-match-card {
  display: grid;
  justify-items: center;
  gap: 13px;
  padding: 34px;
  border-radius: 30px;
  text-align: center;
}

.quick-match-card > p {
  margin: -8px 0 2px;
  color: var(--muted);
}

.quick-match-card > strong {
  color: var(--brown);
  font-size: clamp(2.5rem, 7vw, 4rem);
  line-height: 1;
}

.quick-match-count {
  display: grid;
  grid-template-columns: auto auto;
  align-items: baseline;
  gap: 10px;
  color: var(--muted);
  font-weight: 900;
}

.quick-match-count strong {
  color: var(--brown);
  font-size: 1.35rem;
}

.quick-match-players {
  display: grid;
  width: min(440px, 100%);
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.quick-match-player {
  display: flex;
  min-height: 42px;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  border: 2px solid var(--brown);
  border-radius: 10px;
  background: #fffdf7;
  color: var(--brown);
  font-weight: 900;
  text-align: left;
}

.quick-match-player.empty {
  border-style: dashed;
  color: var(--muted);
}

.quick-match-player-dot {
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
  border: 2px solid var(--brown);
  border-radius: 50%;
  background: var(--green);
}

.quick-match-player-dot.is-cpu {
  background: var(--blue);
}

.quick-match-card .reference-primary {
  width: min(340px, 100%);
}

.quick-match-starting {
  display: inline-flex;
  min-height: 52px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 15px;
  border: 3px solid var(--brown);
  border-radius: 12px;
  background: var(--gold);
  color: var(--brown);
  font-weight: 900;
}

.search-orb {
  display: grid;
  width: 104px;
  height: 104px;
  place-items: center;
  border: 4px solid var(--brown);
  border-radius: 50%;
  background: #ffad73;
}

.search-orb svg {
  width: 54px;
  height: 54px;
  fill: none;
  stroke: var(--brown);
  stroke-width: 2;
}

.search-dots {
  display: flex;
  gap: 10px;
}

.search-dots i {
  width: 15px;
  height: 15px;
  border: 2px solid var(--brown);
  border-radius: 50%;
  background: var(--orange);
}

.search-dots i:nth-child(2) { background: var(--blue); }
.search-dots i:nth-child(3) { background: var(--green); }

.settings-reference-main {
  align-items: start;
}

.settings-reference-panel {
  overflow: hidden;
  border-radius: 26px;
}

.settings-reference-row {
  display: grid;
  min-height: 86px;
  grid-template-columns: 190px minmax(0, 1fr) minmax(0, 1fr);
  align-items: center;
  gap: 24px;
  padding: 16px clamp(18px, 3vw, 36px);
  border-bottom: 2px solid rgba(74, 50, 37, 0.26);
}

.settings-reference-row:last-child { border-bottom: 0; }

.settings-reference-row > div strong {
  display: block;
  color: var(--brown);
  font-size: 1rem;
}

.settings-reference-row > div small { color: var(--muted); }

.settings-reference-row label {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  color: var(--brown);
  font-size: 0.9rem;
  font-weight: 900;
}

.settings-reference-row input[type="range"] {
  min-height: 0;
  padding: 0;
  accent-color: var(--orange);
}

.settings-reference-row output {
  min-width: 38px;
  padding: 4px 7px;
  border-radius: 7px;
  background: var(--brown);
  color: #fff;
  font-size: 0.78rem;
  text-align: center;
}

.settings-reference-row select,
.settings-reference-row input:not([type="range"]):not([type="checkbox"]) {
  min-height: 38px;
  padding: 6px 9px;
  border-width: 3px;
}

.settings-reference-row label:has(select),
.account-settings-row label {
  grid-template-columns: auto minmax(0, 1fr);
}

.toggle-setting {
  grid-template-columns: auto auto !important;
  justify-content: start;
}

.toggle-setting input { display: none; }

.toggle-setting span {
  position: relative;
  width: 58px;
  height: 32px;
  border: 3px solid var(--brown);
  border-radius: 18px;
  background: var(--cream-2);
}

.toggle-setting span::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--brown);
  content: "";
  transition: 150ms ease;
}

.toggle-setting input:checked + span { background: var(--green); }
.toggle-setting input:checked + span::after { transform: translateX(26px); }

.settings-static-note {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.lobby-reference-main { align-items: center; }

.lobby-reference-grid { gap: 34px; }

.lobby-reference-card {
  min-height: 350px;
  padding: clamp(24px, 4vw, 42px);
  border-radius: 30px;
}

.lobby-code-card {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 22px;
  text-align: center;
}

.lobby-code-label {
  display: grid;
  width: fit-content;
  padding: 8px 16px;
  border: 3px solid var(--brown);
  border-radius: 18px;
  background: var(--orange);
  color: #fff;
  font-weight: 900;
}

.lobby-code-label small { color: inherit; }

.lobby-code-characters { gap: 10px; }

.lobby-code-char {
  width: clamp(42px, 7vw, 66px);
  height: clamp(54px, 8vw, 74px);
  border-radius: 14px;
  font-size: clamp(1.6rem, 4vw, 2.75rem);
}

.compact-action {
  display: inline-flex;
  min-height: 60px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 20px;
  background: var(--blue);
  color: #fff;
  white-space: nowrap;
}

.compact-action svg { flex: 0 0 auto; }

.lobby-code-card p {
  margin: 0;
  color: var(--brown);
  font-weight: 900;
}

.lobby-code-card p small { margin-top: 4px; color: var(--muted); }

.lobby-room-options {
  display: grid;
  width: 100%;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
}

.lobby-room-options label,
.lobby-visibility-toggle {
  min-height: 46px;
  border: 3px solid var(--brown);
  border-radius: 12px;
  background: #fffefa;
  color: var(--brown);
  font-size: 0.82rem;
  font-weight: 900;
}

.lobby-room-options label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 9px;
}

.lobby-room-options select {
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--brown);
  font-weight: 900;
}

.lobby-visibility-toggle { padding: 7px 10px; }
.lobby-visibility-toggle.is-public { background: var(--green); color: var(--brown); }

.lobby-confirm-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.lobby-confirm-actions .reference-footer-action,
.lobby-confirm-actions .reference-back {
  min-height: 48px;
  padding: 8px 12px;
  white-space: nowrap;
}

.lobby-player-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.lobby-player-title h2 { margin: 0; }

.lobby-player-count {
  padding: 6px 10px;
  border: 2px solid var(--brown);
  border-radius: 16px;
  background: var(--blue);
  color: #fff;
  font-size: 0.76rem;
  font-weight: 900;
}

.lobby-player-list {
  display: grid;
  gap: 12px;
  margin: 18px 0 0;
  padding: 0;
  list-style: none;
}

.lobby-player-entry {
  display: grid;
  min-height: 56px;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: 3px solid var(--brown);
  border-radius: 14px;
  color: var(--brown);
  font-weight: 900;
}

.lobby-player-entry > span:nth-child(2) { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lobby-player-entry small { text-align: right; }

.lobby-avatar {
  display: block;
  width: 30px;
  height: 30px;
  border: 2px solid var(--brown);
  border-radius: 50%;
  background: var(--green);
  color: var(--brown);
  font-size: 1rem;
  line-height: 26px;
  text-align: center;
}

.lobby-avatar-1 { background: var(--blue); }
.lobby-avatar-2 { background: var(--purple); }
.lobby-avatar-3 { background: var(--gold); }

.empty-lobby-player {
  border-style: dashed;
  color: #a3948a;
}

.empty-lobby-player .lobby-avatar {
  border-style: dashed;
  background: transparent;
}

.work-detail-reference-main {
  grid-template-columns: minmax(0, 1.4fr) minmax(300px, 0.75fr);
  align-items: center;
  gap: 28px;
}

.work-preview-reference-card {
  overflow: hidden;
  padding: 12px;
  border-radius: 24px;
}

.detail-canvas-frame {
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 10;
  border: 3px solid var(--brown);
  border-radius: 14px;
  background: var(--cream-2);
}

.detail-canvas-frame canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.detail-preview-controls {
  display: grid;
  min-height: 50px;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 10px 0 0;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
  text-align: center;
}

.reference-control-button {
  display: inline-flex;
  width: fit-content;
  min-height: 38px;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  border-radius: 11px;
  background: var(--panel);
  font-size: 0.78rem;
}

.detail-preview-controls > :last-child { justify-self: end; }

.work-detail-side {
  display: grid;
  align-content: center;
  gap: 16px;
}

.work-info-reference-card {
  padding: 18px;
  border-radius: 20px;
}

.work-info-reference-card h2 {
  margin: 0 0 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--brown);
}

.work-info-reference-card h2 small { margin-top: 3px; color: var(--muted); }

.detail-name-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.detail-name-field input { min-height: 42px; }

.work-info-reference-card dl {
  display: grid;
  gap: 9px;
  margin: 16px 0 0;
}

.work-info-reference-card dl div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.work-info-reference-card dt { color: var(--muted); font-size: 0.78rem; font-weight: 900; }
.work-info-reference-card dd { margin: 0; color: var(--brown); font-size: 0.86rem; font-weight: 900; text-align: right; }

.reference-action-button {
  display: grid;
  min-height: 62px;
  grid-template-columns: 1fr;
  place-items: center;
  padding: 8px 14px;
  border-radius: 16px;
  background: var(--blue);
  color: #fff;
  font-size: 0.92rem;
}

.reference-action-button small { color: inherit; }
.reference-action-orange { background: var(--orange); }
.reference-action-green { background: #6fae39; color: var(--brown); }
.reference-action-danger { background: #d84d43; }

.match-answer-screen,
.match-results-screen {
  display: grid;
  width: min(var(--layout-content-max-width), 100%);
  min-height: calc(100vh - 28px);
  gap: var(--layout-section-gap);
  margin: 0 auto;
  padding: var(--layout-content-padding);
}

.match-answer-screen {
  grid-template-rows: var(--layout-header-height) minmax(0, 1fr) auto;
}

.match-results-screen {
  grid-template-rows: var(--layout-header-height) minmax(0, 1fr) var(--layout-footer-min-height);
}

.match-screen-header {
  display: grid;
  grid-template-columns: var(--layout-side-column-width) minmax(0, 1fr) var(--layout-side-column-width);
  align-items: center;
  gap: var(--layout-header-gap);
  min-height: var(--layout-header-height);
}

.match-screen-brand {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: center;
}

.match-logo-image {
  width: 150px;
  height: 62px;
  object-position: left center;
}

.match-phase-heading {
  display: grid;
  min-width: min(360px, 42vw);
  justify-items: center;
  justify-self: center;
  padding: 9px 28px 8px;
  border: 4px solid var(--brown);
  border-radius: 24px;
  background: rgba(255, 248, 234, 0.96);
  box-shadow: 0 5px 0 rgba(43, 33, 28, 0.28);
  color: var(--brown);
  text-align: center;
}

.match-phase-heading strong {
  font-size: clamp(1.3rem, 2.3vw, 2rem);
  line-height: 1.05;
  font-weight: 900;
}

.match-answer-screen.is-reveal .match-phase-heading {
  background: var(--green);
  color: var(--brown);
}

.match-phase-heading small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 900;
}

.answer-time-box,
.results-total-label {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  justify-self: end;
  color: var(--brown);
  font-weight: 900;
}

.answer-time-box span,
.results-total-label span {
  font-size: 0.72rem;
}

.answer-time-box strong {
  min-width: 88px;
  padding: 5px 13px;
  border: 4px solid var(--brown);
  border-radius: 16px;
  background: var(--orange);
  box-shadow: 0 4px 0 rgba(43, 33, 28, 0.28);
  color: #fff;
  font-size: clamp(1.45rem, 3vw, 2.2rem);
  line-height: 1;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.results-total-label strong {
  font-size: 1.4rem;
}

.results-total-label #timer {
  min-width: 88px;
  padding: 5px 12px;
  border: 4px solid var(--brown);
  border-radius: 14px;
  background: var(--orange);
  box-shadow: 0 4px 0 rgba(43, 33, 28, 0.28);
  color: #fff;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.answer-workspace {
  display: grid;
  min-height: 0;
  grid-template-columns: minmax(215px, 270px) minmax(0, 1fr);
  gap: 16px;
}

.answer-status-panel,
.answer-work-area,
.answer-submit-bar,
.answer-reveal-bar {
  border: 4px solid var(--brown);
  border-radius: 20px;
  background: rgba(255, 248, 234, 0.96);
  box-shadow: var(--shadow-hard), var(--shadow-soft);
}

.answer-status-panel {
  display: flex;
  min-height: 0;
  flex-direction: column;
  padding: 14px;
}

.answer-status-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 10px;
  border-bottom: 2px solid rgba(74, 50, 37, 0.28);
}

.answer-status-heading h2 {
  margin: 0;
  font-size: 1.05rem;
}

.answer-status-heading span {
  color: var(--orange);
  font-size: 0.82rem;
  font-weight: 900;
}

.answer-player-list {
  display: grid;
  gap: 8px;
  margin-top: 11px;
  overflow: auto;
}

.answer-player-entry {
  display: grid;
  min-height: 64px;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 7px;
  border: 3px solid transparent;
  border-radius: 13px;
}

.answer-player-entry.is-pending {
  background: #fff4dc;
  border-color: #f7c451;
}

.answer-player-entry.is-correct {
  background: #eff8e7;
}

.answer-player-entry.is-incorrect {
  border-color: #dc4a3f;
  background: #fde4df;
}

.answer-player-entry.is-author {
  background: #eaf3fa;
}

.answer-player-avatar,
.result-player-icon {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 3px solid var(--brown);
  border-radius: 50%;
  background: var(--purple);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 900;
}

.answer-player-entry div {
  min-width: 0;
}

.answer-player-entry strong,
.answer-player-entry small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.answer-player-entry strong {
  color: var(--brown);
  font-size: 0.9rem;
}

.answer-player-answer {
  margin-top: 1px;
  font-size: 0.82rem !important;
  font-weight: 900;
}

.answer-player-entry small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 900;
}

.answer-player-entry.is-finished small,
.answer-player-entry.is-correct small {
  color: #43823c;
}

.answer-player-entry.is-incorrect small {
  color: #b63a32;
}

.answer-player-state {
  width: 14px;
  height: 14px;
  border: 3px solid var(--brown);
  border-radius: 50%;
  background: #fff;
}

.answer-player-entry.is-finished .answer-player-state,
.answer-player-entry.is-correct .answer-player-state {
  background: var(--green);
}

.answer-player-entry.is-incorrect .answer-player-state {
  background: #dc4a3f;
}

.answer-player-entry.is-author .answer-player-state {
  background: var(--blue);
}

.answer-work-area {
  position: relative;
  min-height: 0;
  overflow: hidden;
  padding: 8px;
}

.answer-preview-frame {
  height: 100%;
  min-height: 0;
  border-width: 0;
  border-radius: 12px;
  background: #e8edf0;
  box-shadow: none;
}

.answer-preview-frame canvas {
  background: #e8edf0;
}

.answer-preview-frame .canvas-hint {
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  white-space: nowrap;
}

.answer-replay-stage {
  position: absolute;
  top: 14px;
  left: 50%;
  z-index: 3;
  padding: 7px 14px;
  transform: translateX(-50%);
  border: 3px solid var(--brown);
  border-radius: 999px;
  background: rgba(255, 248, 234, 0.94);
  color: var(--brown);
  font-size: 0.82rem;
  font-weight: 900;
  box-shadow: 0 3px 0 rgba(74, 50, 37, 0.22);
  white-space: nowrap;
}

.answer-replay-stage.is-complete {
  background: var(--yellow);
}

.answer-submit-bar,
.answer-reveal-bar {
  display: grid;
  min-height: var(--layout-footer-min-height);
  align-items: center;
  padding: var(--layout-instruction-padding);
}

.answer-submit-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
}

.answer-submit-form input {
  min-width: 0;
  height: 48px;
  padding: 0 16px;
  border: 3px solid var(--brown);
  border-radius: 13px;
  outline: 0;
  background: #fffefa;
  color: var(--brown);
  font-size: 1rem;
  font-weight: 900;
}

.answer-input-note,
.answer-waiting {
  margin: 0;
  color: var(--muted);
  font-weight: 900;
  text-align: center;
}

.answer-reveal-bar {
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
}

.answer-reveal-word {
  display: grid;
  min-width: 120px;
  justify-items: center;
  padding: 4px 12px;
  border-radius: 12px;
  background: #fff0cf;
  color: var(--brown);
}

.answer-reveal-word span,
.answer-reveal-word small {
  font-size: 0.68rem;
  font-weight: 900;
}

.answer-reveal-word strong {
  font-size: 1.35rem;
}

.answer-reveal-message {
  min-width: 0;
  color: var(--brown);
  font-weight: 900;
}

.match-primary-action,
.match-secondary-action {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  padding: 9px 20px;
  border: 4px solid var(--brown);
  border-radius: 16px;
  box-shadow: 0 5px 0 rgba(43, 33, 28, 0.28);
  color: #fff;
  font-weight: 900;
}

.match-primary-action { background: var(--orange); }

.match-secondary-action {
  background: rgba(255, 248, 234, 0.96);
  color: var(--brown);
}

.results-ranking-list {
  display: grid;
  align-content: start;
  gap: 12px;
  min-height: 0;
  overflow: auto;
}

.result-rank-row {
  display: grid;
  min-height: 112px;
  grid-template-columns: 76px minmax(120px, 170px) minmax(160px, 1fr) 122px minmax(130px, 190px);
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border: 4px solid var(--brown);
  border-radius: 18px;
  background: rgba(255, 248, 234, 0.96);
  box-shadow: 0 5px 0 rgba(43, 33, 28, 0.28);
}

.result-rank-row.is-first {
  border-color: #f1b636;
  box-shadow: 0 5px 0 rgba(122, 74, 17, 0.34);
}

.result-rank-number {
  color: var(--brown);
  font-size: 2rem;
  font-weight: 900;
  text-align: center;
}

.result-rank-number small {
  font-size: 0.9rem;
}

.result-player-name {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 9px;
}

.result-player-name strong {
  overflow: hidden;
  color: var(--brown);
  font-size: 1.1rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-score-breakdown {
  display: grid;
  gap: 4px;
  color: var(--brown);
  font-size: 0.84rem;
  font-weight: 900;
}

.result-score-breakdown span {
  width: fit-content;
  padding: 2px 8px;
  border-radius: 9px;
  background: #e7f2f9;
}

.result-score-breakdown span:nth-child(2) { background: #e8f4dd; }

.result-score-breakdown small {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-work-thumb {
  height: 82px;
  border: 3px solid var(--brown);
  border-radius: 12px;
  background: #e8edf0;
}

.result-total-score {
  display: grid;
  justify-items: end;
  color: var(--brown);
  text-align: right;
}

.result-total-score small {
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 900;
}

.result-total-score strong {
  font-size: clamp(1.45rem, 3.3vw, 2.35rem);
  line-height: 1;
}

.match-results-footer {
  display: grid;
  min-height: var(--layout-footer-min-height);
  grid-template-columns: var(--layout-footer-action-width) minmax(0, 1fr) var(--layout-footer-action-width);
  align-items: stretch;
  gap: var(--layout-workspace-gap);
}

.match-results-footer p {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  color: #fff7e8;
  font-size: 0.85rem;
  font-weight: 900;
  text-align: center;
  text-shadow: 0 2px 0 rgba(74, 50, 37, 0.35);
}

.match-results-footer > :last-child {
  justify-self: end;
}

.match-results-footer .match-primary-action,
.match-results-footer .match-secondary-action {
  width: 100%;
  min-height: var(--layout-footer-action-min-height);
}

@media (min-width: 841px) and (min-height: 680px) {
  .work-detail-reference-screen {
    height: calc(100vh - 28px);
    min-height: 0;
    gap: 16px;
    padding-top: var(--layout-content-padding);
    padding-bottom: var(--layout-content-padding);
  }

  .work-detail-reference-screen .reference-header {
    min-height: var(--layout-header-height);
  }

  .work-detail-reference-screen .reference-main {
    min-height: 0;
    gap: 24px;
  }

  .work-detail-reference-screen .work-preview-reference-card {
    padding: 10px;
  }

  .work-detail-reference-screen .detail-canvas-frame {
    aspect-ratio: 16 / 9;
  }

  .work-detail-reference-screen .detail-preview-controls {
    min-height: 44px;
    padding-top: 8px;
  }

  .work-detail-reference-screen .work-detail-side {
    gap: 10px;
  }

  .work-detail-reference-screen .work-info-reference-card {
    padding: 14px;
  }

  .work-detail-reference-screen .reference-action-button {
    min-height: 54px;
  }

  .work-detail-reference-screen .reference-footer {
    min-height: var(--layout-footer-min-height);
  }
}

@media (max-width: 980px) {
  .gallery-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 840px) {
  .reference-screen {
    gap: 24px;
    padding-top: 20px;
  }

  .mode-choice-grid,
  .lobby-reference-grid,
  .work-detail-reference-main {
    grid-template-columns: 1fr;
  }

  .mode-choice { min-height: 280px; }

  .settings-reference-row {
    grid-template-columns: 150px minmax(0, 1fr);
  }

  .settings-reference-row > :last-child { grid-column: 2; }
}

@media (max-width: 700px) {
  .reference-screen {
    min-height: calc(100vh - 16px);
    padding: 16px 4px 12px;
  }

  .reference-header {
    grid-template-columns: 1fr auto;
    gap: 10px;
  }

  .reference-brand b { font-size: 1.05rem; }
  .reference-brand small { font-size: 0.54rem; }
  .reference-blob { width: 56px; height: 44px; border-width: 3px; border-radius: 16px; }
  .reference-title { min-width: 0; padding: 8px 12px; border-width: 3px; border-radius: 16px; }
  .reference-title small { font-size: 0.55rem; }
  .reference-version { display: none; }

  .reference-footer {
    grid-template-columns: 1fr;
    justify-items: stretch;
    gap: 12px;
  }

  .reference-back,
  .reference-footer > .reference-footer-action { width: 100%; justify-self: stretch; }

  .reference-tip { order: 3; }
  .reference-footer > .reference-footer-action { order: 2; }

  .mode-choice { min-height: 245px; padding: 24px; border-radius: 24px; }
  .mode-icon { width: 84px; height: 84px; }
  .mode-icon svg { width: 38px; height: 38px; }
  .join-room-card,
  .quick-match-card,
  .lobby-reference-card { border-radius: 22px; }

  .room-code-inputs { gap: 5px; }
  .room-character { width: min(17vw, 62px); height: 62px; border-radius: 13px; }

  .settings-reference-row {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .settings-reference-row > :last-child { grid-column: auto; }
  .settings-reference-row label { grid-template-columns: auto minmax(0, 1fr) auto; }
  .settings-reference-row label:has(select),
  .account-settings-row label { grid-template-columns: 1fr; }

  .lobby-reference-card { min-height: auto; padding: 24px 18px; }
  .lobby-code-characters { gap: 6px; }
  .lobby-code-char { width: min(15vw, 58px); height: 58px; }
  .lobby-room-options { grid-template-columns: 1fr; }
  .lobby-confirm-actions { align-items: stretch; flex-direction: column; }
  .lobby-confirm-actions .reference-footer-action,
  .lobby-confirm-actions .reference-back { width: 100%; justify-content: center; }
  .lobby-player-title { align-items: flex-start; flex-direction: column; }
  .lobby-player-entry { grid-template-columns: auto minmax(0, 1fr); }
  .lobby-player-entry small { grid-column: 2; text-align: left; }

  .work-detail-reference-main { gap: 20px; }

  .gallery-screen {
    gap: 16px;
    padding: 10px;
  }

  .gallery-header {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .gallery-heading {
    grid-column: 1 / -1;
    grid-row: 1;
    justify-self: center;
  }

  .gallery-logo {
    grid-column: 1;
    grid-row: 2;
  }

  .gallery-sort-control {
    grid-column: 2;
    grid-row: 2;
  }

  .gallery-footer {
    grid-template-columns: 1fr auto;
  }

  .gallery-count {
    display: none;
  }
}

@media (max-height: 760px) and (min-width: 701px) {
  .title-name {
    font-size: 4.8rem;
  }
}

@media (max-width: 1040px) {
  .crafting-screen {
    height: auto;
    min-height: calc(100vh - 28px);
  }

  .crafting-top-bar {
    display: flex;
    height: auto;
    flex-wrap: wrap;
  }

  .mini-logo-group {
    width: auto;
  }

  .speech-bubble {
    order: 3;
    width: 100%;
    max-width: none;
    min-width: 0;
  }

  .main-workspace {
    display: flex;
    flex-direction: column;
  }

  .workspace-toolbar {
    width: 100%;
    flex-basis: auto;
    overflow: visible;
  }

  .shape-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .viewport-container {
    height: min(64vh, 580px);
    min-height: 430px;
    flex: 0 0 auto;
  }

  .layout,
  .results-layout {
    grid-template-columns: 1fr;
  }

  .works-panel {
    max-height: none;
  }
}

@media (max-width: 700px) {
  .app-shell {
    padding: 8px;
  }

  .app-shell::before {
    inset: 8px;
    border-radius: 18px;
  }

  .title-screen,
  .crafting-screen {
    min-height: calc(100vh - 16px);
    border-radius: 18px;
  }

  .title-content {
    min-height: 0;
    padding: 64px 12px 116px;
    gap: 12px;
    transform: translateY(-10px);
  }

  .gallery-grid {
    grid-template-columns: 1fr;
  }

  .gallery-heading {
    min-height: 0;
    padding: 8px 14px;
    border-width: 3px;
    border-radius: 16px;
  }

  .gallery-heading strong { font-size: 1.25rem; }

  .gallery-logo-image {
    width: 142px;
    height: 40px;
  }

  .gallery-sort-control {
    min-width: 120px;
    padding: 5px 8px;
    font-size: 0.64rem;
  }

  .gallery-card-meta {
    padding: 8px 9px 9px;
  }

  .gallery-footer {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .gallery-back-button {
    justify-self: start;
  }

  .gallery-pagination {
    grid-row: 1;
  }

  .title-navigation {
    top: 18px;
    right: 14px;
    left: 14px;
  }

  .title-language-control,
  .title-gallery-button {
    min-height: 40px;
    border-width: 2px;
  }

  .title-gallery-button {
    padding: 7px 10px;
    font-size: 0.82rem;
  }

  .title-footer {
    right: 14px;
    bottom: 72px;
    left: 14px;
    font-size: 0.68rem;
  }

  .title-mobile-ad-slot {
    position: absolute;
    right: 14px;
    bottom: 10px;
    left: 14px;
    display: grid;
    height: 50px;
    place-items: center;
    overflow: hidden;
    border: 1px solid rgba(255, 248, 234, 0.28);
    border-radius: 8px;
    background: rgba(74, 50, 37, 0.14);
    color: rgba(255, 248, 234, 0.58);
    font-size: 0.62rem;
    font-weight: 900;
    letter-spacing: 0.08em;
    pointer-events: none;
  }

  .title-name {
    font-size: 3.4rem;
  }

  .title-logo-image {
    width: min(260px, 62vw);
  }

  .player-card {
    width: min(var(--title-menu-row-width), calc(100vw - 48px));
    padding: 0;
    transform: translateY(-12px);
  }

  .bottom-bar {
    grid-template-columns: 1fr;
  }

  .title-screen .name-input {
    width: 100%;
  }

  .room-join {
    grid-template-columns: 1fr;
  }

  .mini-logo-group {
    width: 112px;
    min-width: 0;
  }

  .mini-logo-image {
    width: 112px;
    height: 54px;
  }

  .mini-logo-text {
    font-size: 18px;
  }

  .top-right-group {
    width: 100%;
    margin-left: 0;
  }

  .works-header {
    align-items: stretch;
    flex-direction: column;
  }

  .craft-badge {
    flex: 1;
  }

  .shape-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .palette-swatches {
    grid-template-columns: repeat(6, minmax(28px, 1fr));
  }

  .library-grid {
    grid-template-columns: 1fr;
  }

  .viewport-container {
    height: 54vh;
    min-height: 360px;
  }

  .viewport-hud {
    left: 12px;
    right: 12px;
    flex-wrap: wrap;
  }

  .instruction-panel {
    width: 100%;
  }

  .instruction-panel span {
    white-space: normal;
  }

  .complete-btn {
    width: 100%;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .player-row,
  .answer-row {
    grid-template-columns: auto minmax(0, 1fr);
  }
}

@media (max-width: 980px) {
  .result-rank-row {
    grid-template-columns: 62px minmax(120px, 1fr) 110px minmax(120px, 160px);
  }

  .result-score-breakdown {
    display: none;
  }
}

@media (max-width: 700px) {
  .match-answer-screen,
  .match-results-screen {
    min-height: calc(100vh - 16px);
    gap: 12px;
    padding: 12px 4px;
  }

  .match-screen-header {
    grid-template-columns: 1fr auto;
    gap: 9px;
  }

  .match-screen-brand { grid-row: 1; }
  .match-logo-image { width: 112px; height: 48px; }

  .match-phase-heading {
    width: 100%;
    min-width: 0;
    grid-column: 1 / -1;
    grid-row: 2;
    padding: 8px 14px;
    border-width: 3px;
    border-radius: 16px;
  }

  .match-phase-heading strong { font-size: 1.25rem; }

  .answer-time-box strong {
    min-width: 70px;
    border-width: 3px;
    border-radius: 12px;
    font-size: 1.35rem;
  }

  .answer-workspace {
    grid-template-columns: 1fr;
  }

  .answer-work-area {
    min-height: 300px;
    padding: 6px;
  }

  .answer-status-panel { order: 2; }
  .answer-player-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .answer-player-entry { min-width: 0; }

  .answer-submit-form,
  .answer-reveal-bar {
    grid-template-columns: 1fr;
  }

  .answer-submit-form .match-primary-action,
  .answer-reveal-bar .match-primary-action { width: 100%; }

  .answer-reveal-word { width: 100%; }
  .answer-reveal-message { text-align: center; }

  .results-ranking-list { overflow: visible; }

  .result-rank-row {
    min-height: 0;
    grid-template-columns: 52px minmax(0, 1fr) 92px;
    gap: 8px;
    padding: 10px;
    border-width: 3px;
    border-radius: 14px;
  }

  .result-rank-number { font-size: 1.5rem; }
  .result-rank-number small { font-size: 0.7rem; }
  .result-player-name strong { font-size: 0.9rem; }
  .result-work-thumb { display: none; }
  .result-total-score strong { font-size: 1.3rem; }

  .match-results-footer {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .match-results-footer > :last-child,
  .match-results-footer .match-secondary-action { width: 100%; justify-self: stretch; }
  .match-results-footer p { order: 3; }
}

@media (min-width: 1920px) {
  .app-shell.title-ad-shell {
    width: min(calc(1272px + 320px + 300px + (var(--app-shell-padding) * 2)), 100%);
  }

  .app-shell.title-ad-shell::before {
    right: calc(160px + 150px + var(--app-shell-padding));
    left: calc(160px + 150px + var(--app-shell-padding));
  }

  .title-ad-shell .title-ad-layout {
    grid-template-columns: 160px 150px minmax(0, 1272px) 150px 160px;
  }

  .title-ad-shell .title-ad-slot {
    display: grid;
    width: 160px;
    height: 600px;
    align-self: center;
    place-items: center;
    border: 1px dashed rgba(255, 248, 234, 0.4);
    border-radius: 12px;
    background: rgba(255, 248, 234, 0.035);
    color: rgba(255, 248, 234, 0.64);
    font-size: 0.75rem;
    font-weight: 900;
    letter-spacing: 0.08em;
    pointer-events: none;
  }

  .title-ad-shell .title-ad-slot-left {
    grid-column: 1;
  }

  .title-ad-shell .title-ad-slot-right {
    grid-column: 5;
  }

  .title-ad-shell .title-screen {
    grid-column: 3;
  }

  .app-shell.ad-reserved-shell {
    width: min(calc(1272px + 320px + 300px + (var(--app-shell-padding) * 2)), 100%);
  }

  .app-shell.ad-reserved-shell::before,
  .app-shell.ad-reserved-shell::after {
    position: absolute;
    top: 50%;
    z-index: 0;
    display: grid;
    width: 160px;
    height: 600px;
    place-items: center;
    border: 1px dashed rgba(255, 248, 234, 0.4);
    border-radius: 12px;
    background: rgba(255, 248, 234, 0.035);
    color: rgba(255, 248, 234, 0.64);
    font-size: 0.75rem;
    font-weight: 900;
    letter-spacing: 0.08em;
    content: "広告";
    pointer-events: none;
    transform: translateY(-50%);
  }

  .app-shell.ad-reserved-shell::before {
    left: var(--app-shell-padding);
  }

  .app-shell.ad-reserved-shell::after {
    right: var(--app-shell-padding);
  }

  .app-shell.ad-reserved-shell > .reference-screen,
  .app-shell.ad-reserved-shell > .gallery-screen,
  .app-shell.ad-reserved-shell > .works-screen,
  .app-shell.ad-reserved-shell > .crafting-screen,
  .app-shell.ad-reserved-shell > .match-answer-screen,
  .app-shell.ad-reserved-shell > .match-results-screen {
    --layout-content-max-width: 1272px;
    margin-right: auto;
    margin-left: auto;
    border-radius: 20px;
    box-shadow: inset 0 0 0 1px rgba(255, 248, 234, 0.12);
  }
}

.mobile-builder-toolbar-header,
.mobile-builder-tools-toggle,
.mobile-viewport-command-grid,
.mobile-tools-backdrop,
.mobile-touch-toolset,
.mobile-depth-controls,
.mobile-rotate-handle {
  display: none;
}

@media (max-width: 700px) {
  .room-code-inputs {
    display: block;
    width: min(100%, 360px);
  }

  .room-character {
    display: none;
  }

  .mobile-room-code-input {
    display: block;
    width: 100%;
    height: 64px;
    margin: 0;
    padding: 0 14px;
    border: 4px solid var(--brown);
    border-radius: 13px;
    background: #fffefa;
    color: var(--brown);
    caret-color: var(--orange);
    font-size: 2rem;
    font-weight: 900;
    letter-spacing: 0.34em;
    line-height: 1;
    text-align: center;
    text-transform: uppercase;
    outline: 0;
  }

  .mobile-room-code-input:focus {
    border-color: var(--orange);
    box-shadow: 0 0 0 4px rgba(255, 123, 48, 0.26);
  }

  .crafting-screen {
    display: grid;
    height: calc(100dvh - 16px);
    min-height: 520px;
    grid-template-rows: auto minmax(0, 1fr) auto 50px;
    gap: 10px;
    padding: 10px;
    overflow: hidden;
  }

  .crafting-top-bar {
    display: grid;
    min-height: 52px;
    grid-template-columns: 104px minmax(0, 1fr) 62px;
    flex: none;
    gap: 8px;
  }

  .mini-logo-group {
    width: 104px;
    min-width: 0;
  }

  .mini-logo-image {
    width: 104px;
    height: 46px;
  }

  .speech-bubble {
    min-height: 42px;
    order: 0;
    padding: 6px 10px;
    border-width: 3px;
    border-radius: 15px;
    font-size: 0.82rem;
  }

  .speech-bubble .prompt-chip {
    position: static;
    margin-right: 6px;
    padding: 2px 6px;
    font-size: 0.62rem;
  }

  .top-right-group { gap: 0; }

  .badge-timer {
    min-width: 62px;
    min-height: 42px;
    padding: 6px 8px;
    border-width: 3px;
    border-radius: 14px;
    font-size: 1.05rem;
  }

  .badge-timer::before { display: none; }

  .main-workspace {
    position: relative;
    display: block;
    min-height: 0;
    overflow: visible;
  }

  .mobile-builder-ad-slot {
    display: grid;
    min-height: 50px;
    place-items: center;
    overflow: hidden;
    border: 1px solid rgba(74, 50, 37, 0.24);
    border-radius: 8px;
    background: rgba(255, 248, 234, 0.32);
    color: rgba(74, 50, 37, 0.46);
    font-size: 0.62rem;
    font-weight: 900;
    letter-spacing: 0.08em;
    pointer-events: none;
  }

  .viewport-container {
    height: 100%;
    min-height: 0;
    border-width: 3px;
    border-radius: 16px;
  }

  .sculpting-canvas {
    min-height: 0;
  }

  .workspace-toolbar {
    position: fixed;
    z-index: 80;
    top: max(8px, env(safe-area-inset-top));
    right: 8px;
    bottom: max(8px, env(safe-area-inset-bottom));
    left: 8px;
    display: flex;
    width: auto;
    max-height: none;
    padding: 12px;
    overflow: auto;
    transform: translateY(calc(100% + 32px));
    border-width: 4px;
    border-radius: 18px;
    opacity: 0;
    pointer-events: none;
    transition: transform 180ms ease, opacity 180ms ease;
  }

  .workspace-toolbar.is-mobile-open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }

  .mobile-builder-toolbar-header {
    display: flex;
    min-height: 42px;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding-bottom: 8px;
    border-bottom: 2px solid rgba(74, 50, 37, 0.28);
    color: var(--brown);
  }

  .mobile-builder-toolbar-header strong { font-size: 1.05rem; }

  .mobile-builder-toolbar-close,
  .mobile-builder-tools-toggle,
  .mobile-touch-mode-button,
  .mobile-depth-controls button,
  .mobile-rotate-handle {
    display: grid;
    place-items: center;
    padding: 0;
    border: 3px solid var(--brown);
    background: var(--panel);
    color: var(--brown);
    box-shadow: 0 4px 0 rgba(74, 50, 37, 0.28);
  }

  .mobile-builder-toolbar-close {
    width: 40px;
    height: 40px;
    border-radius: 12px;
  }

  .mobile-builder-toolbar-close svg,
  .mobile-builder-tools-toggle svg,
  .mobile-touch-mode-button svg,
  .mobile-depth-controls svg,
  .mobile-rotate-handle svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 2.7;
  }

  .workspace-toolbar .viewport-control-dock {
    position: static;
    width: 100%;
    margin-top: 2px;
    padding: 8px;
    border-width: 3px;
    border-radius: 14px;
  }

  .workspace-toolbar .viewport-slider {
    grid-template-columns: 34px minmax(0, 1fr) 68px;
    min-height: 39px;
  }

  .workspace-toolbar .viewport-slider > input[type="range"] { min-height: 26px; }

  .mobile-tools-backdrop {
    position: fixed;
    z-index: 70;
    inset: 0;
    display: block;
    border: 0;
    background: rgba(43, 33, 28, 0.36);
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease;
  }

  .mobile-tools-backdrop.is-open {
    opacity: 1;
    pointer-events: auto;
  }

  .mobile-builder-tools-toggle {
    position: absolute;
    z-index: 10;
    right: 10px;
    bottom: 10px;
    width: 46px;
    height: 46px;
    border-radius: 13px;
  }

  .mobile-viewport-command-grid {
    position: absolute;
    z-index: 10;
    top: 10px;
    right: 10px;
    left: 10px;
    display: grid;
    grid-template-columns: repeat(9, minmax(0, 1fr));
    gap: 2px;
    padding: 3px;
    border: 3px solid var(--brown);
    border-radius: 11px;
    background: rgba(255, 248, 234, 0.94);
    box-shadow: 0 3px 0 rgba(74, 50, 37, 0.22);
  }

  .mobile-viewport-command-grid .command-icon-btn {
    display: grid;
    width: 100%;
    min-height: 0;
    height: 36px;
    aspect-ratio: auto;
    place-items: center;
    padding: 0;
    border-width: 2px;
    border-radius: 7px;
    box-shadow: none;
  }

  .mobile-viewport-command-grid .command-icon-btn svg {
    width: 20px;
    height: 20px;
  }

  .mobile-touch-toolset {
    position: absolute;
    z-index: 10;
    bottom: 10px;
    left: 10px;
    display: flex;
    max-width: calc(100% - 74px);
    gap: 5px;
    padding: 5px;
    border: 3px solid var(--brown);
    border-radius: 15px;
    background: rgba(255, 248, 234, 0.94);
    box-shadow: 0 4px 0 rgba(74, 50, 37, 0.22);
  }

  .mobile-touch-mode-button {
    display: flex;
    width: 48px;
    height: 44px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    border-width: 2px;
    border-radius: 10px;
    box-shadow: none;
  }

  .mobile-touch-mode-button svg {
    width: 16px;
    height: 16px;
  }

  .mobile-touch-mode-button span {
    font-size: 0.58rem;
    font-weight: 900;
    line-height: 1;
    white-space: nowrap;
  }

  .mobile-touch-mode-button.is-active {
    border-color: var(--brown);
    background: var(--orange);
    color: #fff;
  }


  .mobile-depth-controls {
    position: absolute;
    z-index: 10;
    right: 10px;
    bottom: 10px;
    display: flex;
    width: 44px;
    flex-direction: column;
    gap: 4px;
    padding: 4px;
    border: 3px solid var(--brown);
    border-radius: 13px;
    background: rgba(255, 248, 234, 0.94);
    box-shadow: 0 4px 0 rgba(74, 50, 37, 0.22);
  }

  .mobile-depth-controls button {
    width: 34px;
    height: 32px;
    border-width: 2px;
    border-radius: 9px;
    box-shadow: none;
  }

  .mobile-rotate-handle {
    position: absolute;
    z-index: 10;
    right: 10px;
    bottom: 10px;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: #e8f6f4;
  }

  .mobile-rotate-handle.is-rotating {
    transform: translateY(3px);
    box-shadow: 0 1px 0 rgba(74, 50, 37, 0.28);
    background: var(--blue);
    color: #fff;
  }

  .viewport-hud {
    display: none;
    top: 12px;
    right: 12px;
    left: 66px;
    justify-content: flex-end;
  }

  .viewport-hud .hud-pill:last-child { display: none; }

  .hud-pill {
    max-width: 100%;
    padding: 6px 8px;
    border-width: 2px;
    font-size: 0.68rem;
    text-align: right;
  }

  .bottom-bar {
    min-height: 50px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .instruction-panel,
  .builder-footer-spacer { display: none; }

  .builder-back,
  .complete-btn {
    min-height: 50px;
    padding: 8px 12px;
    border-width: 3px;
    border-radius: 14px;
    font-size: 1rem;
  }

  .complete-btn { grid-column: 2; }
  .builder-footer-spacer ~ .complete-btn { grid-column: 1 / -1; }
}


/* Desktop builder side panels: color on the left, compact icon commands on the right. */
.command-icon-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-auto-rows: 1fr;
  gap: 7px;
}

.command-icon-btn {
  display: flex;
  width: 100%;
  min-height: 0;
  aspect-ratio: 1;
  align-items: center;
  justify-content: center;
  padding: 5px;
  line-height: 1;
  border: 3px solid var(--brown);
  border-radius: 12px;
  background: var(--panel);
  color: var(--brown);
  box-shadow: 0 4px 0 rgba(74, 50, 37, 0.22);
  transition: transform 0.1s, box-shadow 0.1s, background 0.15s;
}

.command-icon-btn:hover {
  transform: translateY(2px);
  box-shadow: 0 2px 0 rgba(74, 50, 37, 0.22);
}

.command-icon-btn:active {
  transform: translateY(4px);
  box-shadow: none;
}

.command-icon-btn svg {
  width: 25px;
  height: 25px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.5;
}

.desktop-builder-mode-bar {
  position: absolute;
  z-index: 4;
  top: 16px;
  left: 16px;
  display: flex;
  gap: 6px;
  padding: 5px;
  border: 3px solid var(--brown);
  border-radius: 15px;
  background: rgba(255, 250, 240, 0.94);
  box-shadow: 0 3px 0 rgba(74, 50, 37, 0.22);
}

.desktop-builder-mode-button {
  min-height: 34px;
  padding: 5px 10px;
  border: 2px solid var(--brown);
  border-radius: 9px;
  background: #fffefa;
  color: var(--brown);
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  box-shadow: 0 2px 0 rgba(74, 50, 37, 0.2);
}

.desktop-builder-mode-button.is-active {
  background: var(--orange);
  color: #fff;
}

.command-icon-btn:nth-child(1) { background: #fff0d8; }
.command-icon-btn:nth-child(2) { background: #e8f6f4; }
.command-icon-btn:nth-child(3) { background: #fff6cf; }
.command-icon-btn.is-danger { background: #fff1e8; color: #a13a2d; }

#builderCommandToolbar .viewport-control-dock {
  position: static;
  width: 100%;
  margin-top: 3px;
  gap: 2px;
  padding: 4px 0 0;
  border: 0;
  border-top: 2px solid rgba(74, 50, 37, 0.2);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

#builderCommandToolbar .viewport-slider {
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: 15px 22px;
  column-gap: 6px;
  row-gap: 0;
  min-height: 39px;
  padding: 2px 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

#builderCommandToolbar .viewport-slider > span:not(.viewport-slider-value) {
  grid-column: 1;
  grid-row: 1;
  align-self: center;
  font-size: 11px;
}

#builderCommandToolbar .viewport-slider > input[type="range"] {
  grid-column: 1 / -1;
  grid-row: 2;
}

#builderCommandToolbar .viewport-slider-value {
  display: flex;
  grid-column: 2;
  grid-row: 1;
  align-items: center;
  gap: 1px;
}

#builderCommandToolbar .viewport-slider-value input {
  width: 39px;
}

#builderCommandToolbar .viewport-slider > input[type="range"] {
  height: 22px;
  min-height: 22px;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

#builderCommandToolbar .viewport-slider > input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border: 1px solid rgba(74, 50, 37, 0.24);
  border-radius: 999px;
  background: #eadbcb;
}

#builderCommandToolbar .viewport-slider > input[type="range"]::-webkit-slider-thumb {
  width: 14px;
  height: 14px;
  margin-top: -5px;
  appearance: none;
  -webkit-appearance: none;
  border: 2px solid #fffaf0;
  border-radius: 50%;
  background: var(--orange);
  box-shadow: 0 0 0 1px rgba(74, 50, 37, 0.45);
}

#builderCommandToolbar .viewport-slider > input[type="range"]::-moz-range-track {
  height: 6px;
  border: 1px solid rgba(74, 50, 37, 0.24);
  border-radius: 999px;
  background: #eadbcb;
}

#builderCommandToolbar .viewport-slider > input[type="range"]::-moz-range-thumb {
  width: 10px;
  height: 10px;
  border: 2px solid #fffaf0;
  border-radius: 50%;
  background: var(--orange);
  box-shadow: 0 0 0 1px rgba(74, 50, 37, 0.45);
}

@media (min-width: 701px) {
  #builderToolbar > .toolbar-section:not(#builderColorSection) {
    display: none;
  }

  #builderToolbar,
  #builderCommandToolbar {
    overflow: auto;
  }

  .reference-brand {
    width: var(--layout-logo-width);
  }

  .gallery-logo-image,
  .reference-logo-image,
  .match-logo-image {
    width: var(--layout-logo-width);
    height: var(--layout-logo-height);
    object-position: center;
  }

  .gallery-heading,
  .reference-title,
  .match-phase-heading {
    width: 100%;
    max-width: var(--layout-title-max-width);
    min-width: 0;
    min-height: 58px;
    padding: 10px 16px;
    align-content: center;
    border-radius: 999px;
  }

  .gallery-heading strong,
  .reference-title strong,
  .match-phase-heading strong {
    font-size: 20px;
    line-height: 1.3;
  }
}

@media (min-width: 1041px) {
  .crafting-screen {
    height: min(var(--layout-crafting-max-height), calc(100dvh - 2 * var(--app-shell-padding)));
    min-height: 0;
  }

  .crafting-top-bar,
  .gallery-header,
  .reference-header,
  .match-screen-header {
    grid-template-columns: clamp(180px, 16vw, 200px) minmax(0, 1fr) clamp(180px, 16vw, 200px);
  }

  .mini-logo-group {
    width: 100%;
  }

  .main-workspace {
    grid-template-columns: clamp(180px, 16vw, 200px) minmax(0, 1fr) clamp(172px, 15vw, 190px);
  }
}

@media (min-width: 390px) and (max-width: 700px) {
  .player-card {
    --title-control-height: 48px;
  }

  .title-screen .menu-btn {
    gap: 5px;
    padding: 5px 6px;
  }

  .title-screen .icon-circle {
    width: 28px;
    height: 28px;
  }

  .title-screen .icon-circle svg {
    width: 15px;
    height: 15px;
  }

  .title-screen .btn-label {
    font-size: 0.82rem;
  }
}

@media (max-width: 700px) {
  .desktop-builder-mode-bar {
    display: none;
  }

  #builderToolbar {
    display: none;
  }

  #builderCommandToolbar .command-icon-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  #builderCommandToolbar .command-icon-btn {
    min-height: 58px;
  }

  #builderCommandToolbar .command-icon-grid {
    display: none;
  }

  #builderCommandToolbar .viewport-control-dock {
    gap: 5px;
    padding: 8px;
  }

  #builderCommandToolbar .viewport-slider {
    grid-template-columns: 34px minmax(0, 1fr) 62px;
    grid-template-rows: 34px;
    min-height: 34px;
    column-gap: 6px;
    row-gap: 0;
  }

  #builderCommandToolbar .viewport-slider > span:not(.viewport-slider-value) {
    grid-column: 1;
    grid-row: 1;
    align-self: center;
    font-size: 11px;
  }

  #builderCommandToolbar .viewport-slider > input[type="range"] {
    grid-column: 2;
    grid-row: 1;
    min-height: 26px;
    height: 26px;
  }

  #builderCommandToolbar .viewport-slider-value {
    grid-column: 3;
    grid-row: 1;
    align-self: center;
  }

  #builderCommandToolbar .viewport-slider-value input {
    width: 40px;
  }
  #builderCommandToolbar .palette-swatches {
    grid-template-columns: repeat(auto-fit, minmax(28px, 36px));
    gap: 4px;
  }

  #builderCommandToolbar .swatch,
  #builderCommandToolbar .palette-add-button {
    min-height: 26px;
    width: 100%;
    height: auto;
    aspect-ratio: 1;
    border-radius: 3px;
  }

  #builderCommandToolbar .palette-add-button svg {
    width: 15px;
    height: 15px;
  }
}

@media (max-width: 700px) {
  .title-logo-image {
    width: min(260px, 62vw);
  }

  .title-subtitle {
    font-size: 0.82rem;
    transform: none;
  }

  .player-card {
    --title-menu-row-width: 340px;
    --title-control-height: 48px;
    gap: 8px;
    transform: translateY(-12px);
  }

  .title-screen .name-input {
    padding-inline: 10px;
  }

  .menu-grid {
    width: 100%;
    gap: 8px;
  }

  .menu-row {
    gap: 8px;
  }

  .menu-btn {
    width: calc((100% - 8px) / 2);
    padding: 5px 6px;
  }

  .icon-circle {
    width: 28px;
    height: 28px;
  }

  .btn-label {
    font-size: 0.82rem;
  }
}
@media (min-width: 701px) {
  .title-version {
    position: absolute;
    right: 0;
    bottom: 0;
    order: initial;
  }
}
/*
  Stable responsive profiles.
  PC: 1101px+, iPad/tablet: 701px-1100px, standard phones: 390px-700px,
  and iPhone SE: 389px and below. Adjust the matching block only.
*/
@media (min-width: 1101px) {
  .title-content {
    gap: 64px;
    padding: clamp(20px, 3vh, 30px) 50px;
    transform: translateY(-50px);
  }

  .title-logo-image { width: min(496px, 76vw); }

  .title-subtitle {
    font-size: 1.3rem;
    transform: translateY(-36px);
  }

  .player-card {
    --title-menu-row-width: 550px;
    --title-control-height: 55px;
    gap: 8px;
    transform: translateY(-24px);
  }

  .title-screen .name-input { padding-inline: 13px; }
  .menu-grid { gap: 22px; }
  .menu-row { gap: 40px; }
  .menu-btn {
    width: calc((100% - 40px) / 2);
    padding: 14px 35px;
  }
  .icon-circle {
    width: 32px;
    height: 32px;
  }
  .btn-label { font-size: 1.27rem; }
}

@media (min-width: 701px) and (max-width: 1100px) {
  .title-content {
    height: min(720px, calc(100vh - 28px));
    min-height: 580px;
    gap: 42px;
    padding: 20px 32px;
    transform: translateY(-32px);
  }

  .title-logo-image { width: min(420px, 60vw); }

  .title-subtitle {
    font-size: 1rem;
    transform: translateY(-18px);
  }

  .player-card {
    --title-menu-row-width: 420px;
    --title-control-height: 50px;
    gap: 8px;
    transform: translateY(-16px);
  }

  .title-screen .name-input { padding-inline: 10px; }
  .menu-grid { gap: 14px; }
  .menu-row { gap: 20px; }
  .menu-btn {
    width: calc((100% - 20px) / 2);
    padding: 8px 16px;
  }
  .icon-circle {
    width: 28px;
    height: 28px;
  }
  .btn-label { font-size: 0.98rem; }
}

@media (min-width: 390px) and (max-width: 700px) {
  .title-content {
    min-height: 0;
    padding: 64px 12px 116px;
    gap: 12px;
    transform: translateY(-10px);
  }

  .title-logo-image { width: min(280px, 62vw); }

  .title-subtitle {
    font-size: 0.85rem;
    transform: none;
  }

  .player-card {
    --title-menu-row-width: 360px;
    --title-control-height: 48px;
    gap: 8px;
    transform: translateY(-12px);
  }

  .title-screen .name-input { padding-inline: 10px; }
  .menu-grid { gap: 8px; }
  .menu-row { gap: 8px; }
  .menu-btn {
    width: calc((100% - 8px) / 2);
    padding: 5px 6px;
  }
  .icon-circle {
    width: 28px;
    height: 28px;
  }
  .btn-label { font-size: 0.82rem; }
}

@media (max-width: 389px) {
  .title-content {
    min-height: 0;
    padding: 60px 10px 116px;
    gap: 10px;
    transform: translateY(-8px);
  }

  .title-logo-image { width: min(250px, 66vw); }

  .title-subtitle {
    font-size: 0.78rem;
    transform: none;
  }

  .player-card {
    --title-menu-row-width: 340px;
    --title-control-height: 48px;
    gap: 8px;
    transform: translateY(-12px);
  }

  .title-screen .name-input { padding-inline: 10px; }
  .menu-grid { gap: 8px; }
  .menu-row { gap: 8px; }
  .menu-btn {
    width: calc((100% - 8px) / 2);
    padding: 5px 6px;
  }
  .icon-circle {
    width: 28px;
    height: 28px;
  }
  .btn-label { font-size: 0.78rem; }
}

/* Keep reveal rows inside the status panel instead of growing the answer workspace. */
.answer-workspace {
  overflow: hidden;
}

.answer-status-panel {
  overflow: hidden;
}

.answer-player-list {
  min-height: 0;
  flex: 1 1 auto;
  overscroll-behavior: contain;
}

.match-answer-screen.is-reveal .answer-player-entry {
  min-height: 82px;
}
/*
  Shared mobile chrome.
  The builder is the baseline: 10px screen gutter, 52px header controls,
  and 50px footer actions. Screen-specific content remains in its own area.
*/
@media (max-width: 700px) {
  :root {
    --mobile-screen-gutter: 10px;
    --mobile-chrome-gap: 10px;
    --mobile-header-height: 52px;
    --mobile-header-control-height: 42px;
    --mobile-footer-action-height: 50px;
    --mobile-chrome-border-width: 3px;
    --mobile-chrome-radius: 14px;
    --mobile-logo-width: 104px;
  }

  .reference-screen,
  .gallery-screen,
  .match-answer-screen,
  .match-results-screen {
    --layout-content-padding: var(--mobile-screen-gutter);
    --layout-section-gap: var(--mobile-chrome-gap);
    --layout-header-height: var(--mobile-header-height);
    --layout-footer-min-height: var(--mobile-footer-action-height);
    --layout-footer-action-min-height: var(--mobile-footer-action-height);
    --layout-header-gap: 8px;
    --layout-workspace-gap: var(--mobile-chrome-gap);
    gap: var(--mobile-chrome-gap);
    padding: var(--mobile-screen-gutter);
  }

  .title-navigation {
    top: var(--mobile-screen-gutter);
    right: var(--mobile-screen-gutter);
    left: var(--mobile-screen-gutter);
  }

  .title-language-control,
  .title-gallery-button {
    min-height: var(--mobile-header-control-height);
    border-width: var(--mobile-chrome-border-width);
    border-radius: var(--mobile-chrome-radius);
  }

  .reference-header,
  .gallery-header,
  .match-screen-header {
    min-height: var(--mobile-header-height);
    gap: 8px;
  }

  .reference-header {
    grid-template-columns: var(--mobile-logo-width) minmax(0, 1fr);
  }

  .reference-brand,
  .gallery-logo,
  .match-screen-brand {
    width: var(--mobile-logo-width);
    min-width: 0;
    justify-self: start;
  }

  .reference-logo-image,
  .gallery-logo-image,
  .match-logo-image {
    width: var(--mobile-logo-width);
    height: 46px;
  }

  .reference-title,
  .gallery-heading,
  .match-phase-heading {
    min-width: 0;
    min-height: var(--mobile-header-control-height);
    margin: 0;
    padding: 6px 10px;
    border-width: var(--mobile-chrome-border-width);
    border-radius: var(--mobile-chrome-radius);
    box-shadow: 0 3px 0 rgba(43, 33, 28, 0.28);
  }

  .reference-title {
    width: 100%;
    justify-self: stretch;
  }

  .reference-title strong,
  .gallery-heading strong,
  .match-phase-heading strong {
    overflow: hidden;
    max-width: 100%;
    font-size: 1.05rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .gallery-header {
    grid-template-columns: var(--mobile-logo-width) minmax(0, 1fr) auto;
    grid-template-rows: var(--mobile-header-height);
  }

  .gallery-logo,
  .gallery-heading,
  .gallery-sort-control {
    grid-row: 1;
  }

  .gallery-logo { grid-column: 1; }

  .gallery-heading {
    width: 100%;
    grid-column: 2;
    justify-self: stretch;
  }

  .gallery-sort-control {
    min-width: 76px;
    min-height: var(--mobile-header-control-height);
    grid-column: 3;
    grid-template-columns: 1fr;
    padding: 4px 7px;
    border-width: var(--mobile-chrome-border-width);
    border-radius: var(--mobile-chrome-radius);
    box-shadow: 0 3px 0 rgba(43, 33, 28, 0.28);
  }

  .gallery-sort-control > span { display: none; }

  .gallery-sort-control select {
    min-width: 0;
    min-height: 30px;
    padding-right: 10px;
    font-size: 0.68rem;
    text-align: center;
  }

  .match-screen-header {
    grid-template-columns: var(--mobile-logo-width) minmax(0, 1fr) auto;
    grid-template-rows: var(--mobile-header-height);
  }

  .match-screen-brand,
  .match-phase-heading,
  .answer-time-box,
  .results-total-label {
    grid-row: 1;
  }

  .match-screen-brand { grid-column: 1; }

  .match-phase-heading {
    width: 100%;
    grid-column: 2;
    justify-self: stretch;
  }

  .answer-time-box,
  .results-total-label {
    grid-column: 3;
    align-self: center;
  }

  .answer-time-box strong,
  .results-total-label #timer {
    min-width: 62px;
    min-height: var(--mobile-header-control-height);
    padding: 6px 8px;
    border-width: var(--mobile-chrome-border-width);
    border-radius: var(--mobile-chrome-radius);
    box-shadow: 0 3px 0 rgba(43, 33, 28, 0.28);
    font-size: 1.05rem;
  }

  .reference-footer,
  .gallery-footer,
  .match-results-footer {
    min-height: var(--mobile-footer-action-height);
    gap: var(--mobile-chrome-gap);
  }

  .reference-footer {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .reference-footer:has(.reference-footer-action:empty) {
    grid-template-columns: minmax(0, 1fr);
  }

  .reference-footer-action:empty,
  .reference-tip,
  .match-results-footer p {
    display: none;
  }

  .reference-footer > .reference-footer-action {
    grid-column: 2;
    grid-row: 1;
    order: initial;
  }

  .reference-back,
  .reference-footer-action > button,
  .gallery-back-button,
  .gallery-pagination button,
  .match-results-footer .match-primary-action,
  .match-results-footer .match-secondary-action {
    min-height: var(--mobile-footer-action-height);
    padding: 8px 12px;
    border-width: var(--mobile-chrome-border-width);
    border-radius: var(--mobile-chrome-radius);
    box-shadow: 0 4px 0 rgba(43, 33, 28, 0.28);
  }

  .gallery-footer {
    grid-template-columns: minmax(0, 1fr) auto;
    justify-items: stretch;
  }

  .gallery-back-button {
    grid-column: 1;
    grid-row: 1;
    justify-self: stretch;
  }

  .gallery-pagination {
    grid-column: 2;
    grid-row: 1;
    align-self: stretch;
  }

  .match-results-footer {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .match-results-footer > :last-child,
  .match-results-footer .match-secondary-action {
    width: 100%;
    justify-self: stretch;
  }

  .answer-submit-bar,
  .answer-reveal-bar {
    min-height: 58px;
    padding: 5px;
    border-width: var(--mobile-chrome-border-width);
    border-radius: var(--mobile-chrome-radius);
    box-shadow: 0 4px 0 rgba(43, 33, 28, 0.28);
  }

  .answer-submit-form {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
  }

  .answer-submit-form input,
  .answer-submit-form .match-primary-action {
    min-height: var(--mobile-header-control-height);
    height: var(--mobile-header-control-height);
    border-width: 3px;
    border-radius: 12px;
  }

  .answer-submit-form .match-primary-action {
    width: auto;
    padding: 6px 12px;
  }

  .answer-reveal-bar {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
  }

  .answer-reveal-word {
    display: none;
  }

  .answer-reveal-bar .match-primary-action {
    width: auto;
    min-height: var(--mobile-header-control-height);
    padding: 6px 12px;
    border-width: 3px;
    border-radius: 12px;
  }

  .title-footer {
    right: var(--mobile-screen-gutter);
    bottom: 72px;
    left: var(--mobile-screen-gutter);
    min-height: var(--mobile-header-control-height);
    align-content: center;
  }

  .title-mobile-ad-slot {
    right: var(--mobile-screen-gutter);
    bottom: var(--mobile-screen-gutter);
    left: var(--mobile-screen-gutter);
    height: var(--mobile-footer-action-height);
  }
}

@media (max-width: 389px) {
  .crafting-top-bar .speech-bubble {
    flex-direction: column;
    gap: 1px;
    padding: 3px 6px;
    font-size: 12px;
    line-height: 1.2;
  }

  .crafting-top-bar .speech-bubble .prompt-chip {
    margin-right: 0;
    padding: 1px 5px;
    font-size: 9px;
  }
}

.local-repair-button {
  position: absolute;
  top: 72px;
  left: 16px;
  z-index: 5;
  min-width: 72px;
  height: 36px;
  cursor: pointer;
}

@media (max-width: 700px) {
  .mobile-touch-toolset.has-smooth-mode { gap: 4px; }
  .has-smooth-mode .mobile-touch-mode-button { width: 44px; min-width: 0; padding: 0; }
}

@media (max-width: 700px) {
  .local-repair-button {
    top: 64px;
    left: 8px;
    min-width: 62px;
    height: 34px;
    font-size: 12px;
  }
}

/* Ad reservations are intentionally disabled until the ad integration is enabled. */
@media (max-width: 700px) {
  .crafting-screen {
    grid-template-rows: auto minmax(0, 1fr) auto;
  }

  .title-content {
    padding-bottom: 68px;
  }

  .title-footer {
    bottom: var(--mobile-screen-gutter);
  }
}
