:root {
  --ink: #231f20;
  --paper: #fff7e9;
  --wood: #d99b64;
  --wood-dark: #b67947;
  --belt: #32363d;
  --blue: #2478a8;
  --green: #1f9b65;
  --red: #d64134;
  --gold: #f0b43c;
  --shadow: 0 18px 45px rgba(0,0,0,.18);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  background: #ece7dd;
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'%3E%3Cpath d='M12 3c2 0 3 1 3 3v7l1-1c2-1 4 0 4 2v1l1-1c2-1 4 0 4 2v4c0 6-4 10-10 10h-2c-4 0-7-2-8-6l-2-7c0-2 2-3 4-2l2 3V6c0-2 1-3 3-3z' fill='white' stroke='black' stroke-width='2'/%3E%3C/svg%3E") 8 2, pointer;
}

button, input {
  font: inherit;
}

button {
  min-height: 42px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  padding: 8px 14px;
  background: #fffdf7;
  color: var(--ink);
  font-weight: 800;
  cursor: inherit;
  box-shadow: 0 4px 0 rgba(0,0,0,.18);
}

button:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0,0,0,.18); }
.primary { color: #fff; background: var(--green); }
.alarm-btn { color: #fff; background: var(--red); }
.phone-btn { color: #fff; background: var(--blue); }
.soap-btn { color: #1f342d; background: #a8f0cf; }
body.soap-mode .soap-btn { background: #36d385; box-shadow: 0 0 0 4px rgba(54,211,133,.28); }
.icon { width: 46px; padding: 0; font-size: 22px; }

.screen { display: none; min-height: 100vh; padding: 20px; }
.screen.active { display: block; }

.mode-screen.active {
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #83bfd0, #f2d49f);
}

.mode-card {
  width: min(680px, 94vw);
  padding: 28px;
  border: 4px solid var(--ink);
  border-radius: 18px;
  background: #fff7e9;
  box-shadow: var(--shadow);
  text-align: center;
}

.mode-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin: 22px 0;
}

.mode-options button {
  min-height: 150px;
  display: grid;
  align-content: center;
  gap: 10px;
}

.mode-options strong { font-size: 28px; }
.mode-options span { color: #5d544c; font-weight: 700; line-height: 1.5; }

.home.active {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  gap: 0;
  align-items: stretch;
  padding: 0;
  min-height: 100vh;
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  overflow: hidden;
  background: linear-gradient(90deg, #8fa8b0 0 58%, #24424a 58% 100%);
}

.hero-board, .home-panel, .card, .result-card {
  border: 3px solid var(--ink);
  border-radius: 10px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.hero-board {
  height: 100vh;
  min-height: 0;
  padding: 0;
  position: relative;
  overflow: hidden;
  background: #17333b;
  border-width: 0 3px 0 0;
  border-radius: 0;
}

.cover-image {
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: cover;
  display: block;
}

.shelf-art {
  display: none;
}

.shelf-art span {
  display: inline-grid;
  place-items: center;
  min-width: 68px;
  height: 48px;
  margin: 8px 5px;
  border: 3px solid #183446;
  border-radius: 16px;
  background: #ffd166;
  font-weight: 900;
  rotate: var(--tilt, -5deg);
}
.shelf-art span:nth-child(2n) { background: #8bd3dd; --tilt: 6deg; }
.shelf-art span:nth-child(3n) { background: #f4a0bd; --tilt: -8deg; }

.cover-worker {
  display: none;
}

.worker-head {
  position: absolute;
  left: 75px;
  top: 0;
  width: 130px;
  height: 132px;
  border: 5px solid #183446;
  border-radius: 48% 52% 44% 46%;
  background: #ffd0a8;
  box-shadow: inset -12px -10px 0 rgba(205,116,67,.28);
}
.worker-head::before {
  content: "";
  position: absolute;
  left: -6px;
  top: -24px;
  width: 132px;
  height: 58px;
  border: 5px solid #183446;
  border-radius: 68px 42px 22px 22px;
  background: #ad4f2a;
}
.worker-head::after {
  content: "";
  position: absolute;
  left: 28px;
  top: 62px;
  width: 72px;
  height: 24px;
  border-top: 6px solid #183446;
  border-bottom: 4px solid #183446;
  border-radius: 6px;
  box-shadow: 0 25px 0 -10px #aa5f4f;
}
.worker-body {
  position: absolute;
  left: 28px;
  top: 120px;
  width: 190px;
  height: 138px;
  border: 5px solid #183446;
  border-radius: 34px 34px 10px 10px;
  background: #f7fbff;
}
.worker-body::before {
  content: "";
  position: absolute;
  inset: 16px auto auto 22px;
  width: 52px;
  height: 92px;
  border-right: 8px solid #438ac2;
  border-bottom: 8px solid #438ac2;
}
.worker-arm {
  position: absolute;
  left: 120px;
  top: 130px;
  width: 104px;
  height: 38px;
  border: 5px solid #183446;
  border-radius: 22px;
  background: #ffd0a8;
  rotate: 42deg;
}

.cover-speech {
  position: absolute;
  left: 54%;
  top: 13%;
  max-width: 280px;
  padding: 16px 20px;
  border: 5px solid #183446;
  border-radius: 22px;
  background: #f4f6c8;
  font-size: 20px;
  line-height: 1.5;
  font-weight: 900;
  box-shadow: 0 8px 0 rgba(24,52,70,.22);
}

.cover-shelf {
  position: absolute;
  left: 4%;
  top: 7%;
  width: min(620px, 72%);
  height: 48%;
  padding: 24px;
  border: 5px solid #183446;
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.12), rgba(255,255,255,0)),
    repeating-linear-gradient(0deg, #236f92 0 92px, #174e6a 93px 104px);
  box-shadow: 0 18px 0 rgba(0,0,0,.18);
}

.cover-shelf img {
  width: 96px;
  height: 78px;
  object-fit: contain;
  margin: 14px 18px;
  filter: drop-shadow(0 8px 0 rgba(0,0,0,.2));
  rotate: var(--tilt, -5deg);
}

.cover-shelf img:nth-child(2n) { --tilt: 5deg; }
.cover-shelf img:nth-child(3n) { --tilt: -9deg; }

.mini-desk {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  min-height: 310px;
  border: 0;
  border-top: 5px solid #734928;
  border-radius: 0;
  padding: 24px;
  background:
    linear-gradient(#e5ad73 0 22%, #d9955a 22% 24%, transparent 24%),
    repeating-linear-gradient(0deg, #e7ad74 0 54px, #d18a50 55px 58px);
  position: relative;
}

.mini-desk img {
  width: 92px;
  height: 76px;
  object-fit: contain;
  margin: 18px;
  filter: drop-shadow(0 8px 0 rgba(80,45,23,.22));
  rotate: var(--r, -4deg);
}

.mini-desk img:nth-child(2n) { --r: 5deg; }
.mini-desk img:nth-child(3n) { --r: -8deg; }

.mini-desk i {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 82px;
  height: 62px;
  margin: 12px;
  border: 4px solid #183446;
  border-radius: 18px;
  background: #fffdf7;
  font-style: normal;
  font-weight: 900;
  rotate: var(--r, -4deg);
  box-shadow: 0 8px 0 rgba(80,45,23,.22), inset -8px -8px 0 rgba(0,0,0,.07);
}
.mini-desk i:nth-child(2n) { --r: 5deg; }
.mini-desk i:nth-child(3n) { --r: -8deg; }

.home-panel {
  padding: clamp(24px, 4vw, 46px);
  background: linear-gradient(90deg, rgba(17, 38, 45, .72), rgba(17, 38, 45, .9));
  color: #fff;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  display: grid;
  align-content: start;
  justify-items: center;
  padding-top: clamp(18px, 3vh, 34px);
}
.eyebrow { margin: 0 0 10px; color: var(--blue); font-weight: 900; }
h1, h2, h3, p { overflow-wrap: anywhere; }
h1 { margin: 0; font-size: clamp(38px, 7vw, 72px); line-height: 1.06; }
h2 { margin: 0; font-size: clamp(28px, 5vw, 44px); }
h3 { margin: 0 0 12px; font-size: 22px; }
.home-panel .eyebrow { color: #ffe66d; }
.intro { color: rgba(255,255,255,.82); font-size: 18px; line-height: 1.7; }
.student { display: grid; gap: 8px; padding: 14px; border: 2px dashed var(--blue); font-weight: 900; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }

.cover-logo {
  display: grid;
  justify-items: center;
  width: min(340px, 100%);
  margin-bottom: 28px;
  padding: 12px 22px;
  border: 7px solid #fff;
  border-radius: 18px;
  background: #ffe554;
  color: #050505;
  box-shadow: 0 8px 0 #23472f, 0 0 0 4px #050505;
  rotate: -2deg;
}

.cover-logo span { font-size: clamp(36px, 4.2vw, 58px); font-weight: 1000; line-height: 1; white-space: nowrap; }
.cover-logo strong { margin-top: -4px; color: #65dd45; font-size: clamp(24px, 3vw, 38px); text-shadow: 2px 2px #111; }

.menu-actions {
  width: min(320px, 100%);
  display: grid;
}

.menu-actions button {
  width: 100%;
  border-color: transparent;
  background: rgba(10, 24, 28, .62);
  color: #fff;
  box-shadow: none;
  font-size: 24px;
}

.menu-actions .primary { background: rgba(10, 24, 28, .82); }
.version { color: rgba(255,255,255,.72); font-weight: 900; }

.game { padding: 10px; background: #d8d8d8; overflow: hidden; }
.game.active { display: grid; grid-template-rows: auto 1fr; gap: 8px; }

.hud {
  display: grid;
  grid-template-columns: 46px repeat(3, minmax(86px, 1fr)) 88px;
  gap: 8px;
  align-items: center;
}

.hud-card {
  min-height: 54px;
  border: 3px solid var(--ink);
  border-radius: 8px;
  background: #fffdf7;
  padding: 6px 10px;
  text-align: center;
}
.hud-card span { display: block; font-size: 12px; font-weight: 900; color: #6a6259; }
.hud-card strong { font-size: 25px; color: var(--green); }

.game-board {
  position: relative;
  min-height: 0;
  display: grid;
  grid-template-rows: 126px 1fr;
  border: 3px solid var(--ink);
  border-radius: 10px;
  overflow: hidden;
  background: #bbb;
}

.customer-zone {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 10px;
  background: linear-gradient(#f7f7f7, #d8d8d8);
  border-bottom: 3px solid var(--ink);
}

.customer {
  position: relative;
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.customer-slot.empty {
  min-height: 106px;
}

.avatar {
  width: 58px;
  height: 58px;
  border: 3px solid var(--ink);
  border-radius: 50% 50% 44% 44%;
  background: #ffd0b0;
  position: relative;
  overflow: visible;
}
.avatar img {
  position: absolute;
  left: -12px;
  top: -32px;
  width: 88px;
  height: 92px;
  object-fit: contain;
  filter: drop-shadow(0 4px 0 rgba(0,0,0,.18));
}
.avatar.image-avatar {
  border-color: transparent;
  background: transparent;
  box-shadow: none !important;
}
.avatar.image-avatar::before,
.avatar.image-avatar::after {
  display: none;
}
.customer .avatar.image-avatar {
  box-shadow: none !important;
}
.avatar::before {
  content: "";
  position: absolute;
  left: 9px;
  top: -10px;
  width: 36px;
  height: 20px;
  border-radius: 18px 18px 8px 8px;
  background: #7b4b2f;
  border: 2px solid var(--ink);
}
.avatar::after {
  content: "";
  position: absolute;
  left: 14px;
  top: 24px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 0 0, #222 0 6px, transparent 7px),
    radial-gradient(circle at 26px 0, #222 0 6px, transparent 7px);
  box-shadow: 22px 0 0 #222, 11px 14px 0 -2px #c7655b;
}
.customer.suspect .avatar { background: #333; }
.customer.suspect .avatar::before {
  left: 5px;
  top: -12px;
  width: 44px;
  height: 22px;
  border-radius: 4px 4px 0 0;
  background: #050505;
}
.customer.suspect .avatar::after {
  left: 13px;
  top: 24px;
  background: #f5f5f5;
  box-shadow: 24px 0 0 #f5f5f5, 12px 13px 0 -2px #111;
}
.hair-red .avatar::before { background: #d94b3d; }
.hair-blond .avatar::before { background: #d9a45d; }
.hair-brown .avatar::before { background: #8a5535; }
.hair-black .avatar::before { background: #2a2523; }
.hair-green .avatar::before { background: #68a357; }
.hair-purple .avatar::before { background: #8c65c9; }
.shirt-pink .avatar { box-shadow: 0 20px 0 3px #ef8fb4; }
.shirt-blue .avatar { box-shadow: 0 20px 0 3px #72b7df; }
.shirt-green .avatar { box-shadow: 0 20px 0 3px #82c978; }
.shirt-orange .avatar { box-shadow: 0 20px 0 3px #e6a25d; }
.shirt-violet .avatar { box-shadow: 0 20px 0 3px #9b87d9; }
.customer.suspect .avatar { box-shadow: 0 20px 0 3px #111; }
.customer.suspect .avatar.image-avatar {
  background: transparent !important;
  border-color: transparent !important;
  box-shadow: none !important;
}
.customer.suspect .avatar.image-avatar::before,
.customer.suspect .avatar.image-avatar::after {
  display: none !important;
}

.bubble {
  position: relative;
  min-height: 80px;
  border: 3px solid var(--ink);
  border-radius: 18px;
  background: #fff;
  padding: 10px;
  font-weight: 900;
  display: grid;
  align-content: center;
  box-shadow: 0 4px 0 rgba(0,0,0,.14);
}
.bubble small { display: block; color: #6c6259; margin-top: 4px; }
.customer.suspect .bubble {
  background: #111;
  color: #fff;
  border-color: #000;
}
.customer-actions { margin-top: 3px; display: flex; gap: 6px; }
.customer-actions button { min-height: 24px; padding: 1px 8px; font-size: 12px; border-radius: 6px; line-height: 1; }
.wait-bar {
  height: 8px;
  margin-top: 3px;
  border: 2px solid #222;
  border-radius: 10px;
  overflow: hidden;
  background: #d8d8d8;
}
.wait-bar span {
  display: block;
  height: 100%;
  width: 100%;
  background: #43b7e8;
  transform-origin: left center;
  transition: transform .2s linear;
}

.work-zone {
  min-height: 0;
  display: grid;
  grid-template-columns: 170px 1fr;
}

.belt-panel {
  border-right: 3px solid var(--ink);
  background: #2f333a;
  color: #fff;
  display: block;
  min-height: 0;
}

.conveyor {
  position: relative;
  height: 100%;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 42px, #616773 0 38px, transparent 39px),
    repeating-linear-gradient(0deg, #454b54 0 34px, #2d3037 34px 38px);
}
.conveyor::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent, rgba(0,0,0,.18));
  pointer-events: none;
}

.desk {
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(#efbd86 0 17%, #cf8850 17% 18%, transparent 18%),
    repeating-linear-gradient(0deg, #dfa66f 0 62px, #c97f49 63px 67px);
}

.item {
  position: absolute;
  width: 68px;
  height: 58px;
  border: 0;
  padding: 0;
  background: transparent;
  box-shadow: none;
  touch-action: none;
  cursor: inherit;
}
.item:active { cursor: inherit; transform: none; box-shadow: none; }
.picture {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 14px;
  background: transparent;
  font-size: 32px;
  box-shadow: none;
  filter: drop-shadow(0 7px 0 rgba(0,0,0,.17));
  overflow: hidden;
}
.picture img { width: 100%; height: 100%; object-fit: contain; }
.svg-icon { width: 100%; height: 100%; display: block; }
.emoji-icon { font-size: 34px; line-height: 1; }
.item.on-desk .picture { border-color: transparent; background: transparent; box-shadow: none; }
.item.on-desk .name-tag { display: none; }
.item.dragging { z-index: 20; }
.item.dragging .name-tag, .item.on-belt .name-tag {
  display: block;
}

.name-tag {
  position: absolute;
  left: 54px;
  top: 2px;
  translate: 0 0;
  padding: 3px 7px;
  border-radius: 5px;
  background: #161616;
  color: #fff;
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
  pointer-events: none;
}

.item.dirty .picture::after {
  content: "";
  position: absolute;
  inset: 7px;
  border-radius: 14px;
  background:
    radial-gradient(circle at 20% 30%, rgba(96,68,42,.45) 0 7px, transparent 8px),
    radial-gradient(circle at 70% 55%, rgba(76,54,35,.38) 0 9px, transparent 10px),
    radial-gradient(circle at 46% 72%, rgba(96,68,42,.32) 0 6px, transparent 7px);
  pointer-events: none;
}

.clean-pop .picture {
  animation: cleanPop .55s ease;
}

@keyframes cleanPop {
  0% { filter: brightness(1); }
  50% { filter: brightness(1.45) saturate(1.4); transform: scale(1.08); }
  100% { filter: brightness(1); transform: scale(1); }
}

.cash-note {
  position: absolute;
  z-index: 9;
  width: 74px;
  min-height: 34px;
  padding: 3px 8px;
  border: 3px solid #a84855;
  border-radius: 5px;
  background:
    radial-gradient(circle at 12px 50%, rgba(255,255,255,.8) 0 6px, transparent 7px),
    linear-gradient(135deg, #ffd5dc, #f38aa0);
  color: #44242a;
  font-weight: 900;
  box-shadow: 0 5px 0 rgba(90, 45, 32, .18);
}
.cash-note span { font-size: 13px; margin-right: 3px; }
.cash-note strong { font-size: 18px; }

.smile-token {
  position: absolute;
  z-index: 8;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 3px solid #0f5f24;
  border-radius: 50%;
  background: #58d847;
  color: #073713;
  font-size: 30px;
  font-weight: 900;
  box-shadow: 0 4px 0 rgba(0,0,0,.18);
  left: 50%;
  top: 50%;
  translate: -50% -50%;
  animation: facePop 1s ease forwards;
}

.smile-token::before {
  content: "";
  width: 21px;
  height: 15px;
  border-bottom: 4px solid currentColor;
  border-radius: 0 0 18px 18px;
  transform: translateY(3px);
}

.smile-token::after {
  content: "";
  position: absolute;
  width: 5px;
  height: 5px;
  left: 11px;
  top: 11px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 14px 0 0 currentColor;
}

.cry-token {
  background: #62b5ff;
  color: #0e385f;
  border-color: #145f9e;
}

.cry-token::before {
  border-bottom: 0;
  border-top: 4px solid currentColor;
  border-radius: 18px 18px 0 0;
  transform: translateY(8px);
}

@keyframes facePop {
  0% { opacity: 0; scale: .7; }
  15% { opacity: 1; scale: 1; }
  85% { opacity: 1; scale: 1; }
  100% { opacity: 0; scale: .7; }
}

.teacher, .guide, .result { background: #f2eadc; }
.page-head { display: flex; gap: 12px; align-items: center; max-width: 1120px; margin: 0 auto 16px; }
.teacher-layout { display: grid; grid-template-columns: 340px 1fr; gap: 16px; max-width: 1120px; margin: 0 auto; }
.card { padding: 18px; }
label { display: grid; gap: 5px; margin-bottom: 10px; font-weight: 900; }
input { min-height: 40px; border: 2px solid var(--ink); border-radius: 8px; padding: 8px; background: #fffdf7; }
.checkbox { display: flex; align-items: center; gap: 8px; }
.canvas-tools { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.canvas-tools button { min-height: 32px; padding: 4px 9px; font-size: 13px; }
canvas { width: 100%; border: 3px solid var(--ink); border-radius: 8px; background: white; touch-action: none; }
.status { min-height: 24px; color: var(--blue); font-weight: 900; }
.word-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; max-height: 70vh; overflow: auto; }
.word-chip { border: 2px solid var(--ink); border-radius: 8px; padding: 8px; background: #fffdf7; font-weight: 900; }
.word-chip small { display: block; color: #6b6258; font-weight: 700; }
.mini-delete {
  min-height: 30px;
  margin-top: 8px;
  padding: 2px 9px;
  border-radius: 6px;
  background: #ffe1dd;
  color: #9b2f25;
  font-size: 13px;
}

.guide-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; max-width: 1000px; margin: 0 auto; }
.guide-grid p { line-height: 1.75; color: #5d544c; }

.result.active { display: grid; place-items: center; }
.result-card { width: min(760px, 100%); padding: 24px; }
.result-card h2.outcome-red { color: #d62222; }
.result-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 18px; }
.stat { border: 2px solid var(--ink); border-radius: 8px; padding: 14px; background: #fffdf7; }
.stat strong { display: block; color: var(--green); font-size: 28px; }

.phone-panel {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 18;
  width: 184px;
  border: 4px solid #151515;
  border-radius: 20px;
  padding: 10px;
  background: rgba(38, 50, 56, .96);
  color: #fff;
  box-shadow: var(--shadow);
}
.phone-panel.phone-pulse {
  animation: phonePulse .52s ease;
}
@keyframes phonePulse {
  0%, 100% { transform: scale(1); }
  45% { transform: scale(1.04); }
}
.phone-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  font-size: 14px;
}
.mini {
  width: 34px;
  min-height: 34px;
  padding: 0;
  border-radius: 50%;
}
.phone-list {
  display: grid;
  gap: 6px;
  max-height: 74px;
  overflow: auto;
  padding: 6px;
  border-radius: 12px;
  background: #eaf7ff;
  color: #1c2b31;
}
.phone-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 6px;
  border-radius: 8px;
  background: #fff;
  font-weight: 900;
  border: 0;
  min-height: 30px;
  color: #1c2b31;
  box-shadow: none;
  font-size: 12px;
}
.phone-empty {
  padding: 10px;
  border-radius: 8px;
  background: #fff;
  color: #5b6770;
  text-align: center;
  font-weight: 900;
}
.phone-display {
  margin: 8px 0;
  padding: 8px;
  border-radius: 12px;
  background: #101820;
  color: #ffe66d;
  text-align: center;
  font-size: 18px;
  font-weight: 900;
}
.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.keypad button {
  min-height: 34px;
  padding: 4px;
  border-radius: 10px;
  background: #f2f6f8;
  font-size: 13px;
}

.clean-modal {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: grid;
  place-items: center;
  background: rgba(15, 23, 42, .72);
  touch-action: none;
  user-select: none;
}
.clean-modal[hidden] { display: none !important; }
.clean-stage {
  position: relative;
  width: min(620px, 92vw);
  min-height: 420px;
  padding: 24px;
  overflow: hidden;
  background: #fff;
  border-radius: 24px;
  box-shadow: 0 24px 80px rgba(0,0,0,.35);
  display: grid;
  place-items: center;
}
.clean-title {
  position: absolute;
  top: 0;
  z-index: 2;
  padding: 8px 18px;
  border: 3px solid #222;
  border-radius: 12px;
  background: #fff7d5;
  font-weight: 900;
}
.clean-progress {
  position: absolute;
  left: 50%;
  bottom: 18px;
  translate: -50% 0;
  width: min(280px, 54vw);
  height: 14px;
  border: 3px solid #222;
  border-radius: 999px;
  background: #f2eadc;
  overflow: hidden;
}
.clean-progress span {
  display: block;
  width: 0%;
  height: 100%;
  background: #65dd45;
  transition: width .12s ease;
}
.clean-preview {
  position: relative;
  width: min(440px, 80vw);
  height: min(340px, 64vw);
  display: grid;
  place-items: center;
  filter: drop-shadow(0 18px 0 rgba(0,0,0,.22));
}
.clean-preview .svg-icon {
  width: 100%;
  height: 100%;
}
.clean-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.clean-preview.dirty-big::after {
  content: "";
  position: absolute;
  width: min(440px, 80vw);
  height: min(340px, 64vw);
  opacity: calc(1 - var(--clean-progress, 0));
  background:
    radial-gradient(circle at 34% 28%, rgba(54,31,20,.8) 0 22px, transparent 24px),
    radial-gradient(circle at 59% 44%, rgba(54,31,20,.72) 0 28px, transparent 30px),
    radial-gradient(circle at 42% 66%, rgba(54,31,20,.62) 0 20px, transparent 22px);
}
.clean-shine {
  animation: cleanPop .55s ease;
}
.sponge {
  position: absolute;
  right: 20px;
  bottom: 34px;
  width: 82px;
  height: 58px;
  border-radius: 20px;
  background: #ffd047;
  font-size: 32px;
  touch-action: none;
  z-index: 4;
  user-select: none;
  cursor: grab;
}
.sponge:active { cursor: grabbing; }

.rotate-tip {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  place-items: center;
  padding: 24px;
  background: rgba(8, 22, 27, .88);
  color: #fff;
  text-align: center;
}
.rotate-tip div {
  max-width: 360px;
  padding: 24px;
  border: 4px solid #fff;
  border-radius: 18px;
  background: #102f36;
  box-shadow: 0 10px 0 rgba(0,0,0,.24);
}
.rotate-tip strong {
  display: block;
  font-size: 30px;
  margin-bottom: 10px;
}
.rotate-tip span {
  font-weight: 800;
  line-height: 1.6;
}

@media (max-width: 860px) {
  .teacher-layout, .guide-grid { grid-template-columns: 1fr; }
  .home.active {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(190px, 34vw);
    position: relative;
    background: #112b33;
  }
  .home.active .hero-board {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    border: 0;
  }
  .home.active .cover-image {
    object-fit: cover;
    object-position: center 22%;
    background: #0d2a31;
  }
  .home.active .home-panel {
    position: static;
    display: grid;
    align-content: start;
    padding: 8px 10px;
    background: linear-gradient(90deg, rgba(43, 78, 86, .94), rgba(12, 34, 40, .96));
  }
  .home-panel .cover-logo {
    width: min(210px, 100%);
    padding: 6px 11px;
    border-width: 5px;
    margin-bottom: 10px;
  }
  .home-panel .cover-logo span {
    font-size: clamp(24px, 6vw, 36px);
  }
  .home-panel .cover-logo strong {
    font-size: clamp(14px, 3.8vw, 22px);
  }
  .student {
    font-size: 10px;
    padding: 7px;
    gap: 4px;
  }
  .actions { margin-top: 9px; gap: 6px; }
  .menu-actions button {
    font-size: 15px;
    min-height: 34px;
  }
  .version { margin: 5px 0 0; font-size: 11px; }
  .mode-options { grid-template-columns: 1fr; }
  .hero-board { min-height: 390px; }
  .game {
    padding: 4px;
  }
  .game.active {
    grid-template-rows: 40px 1fr;
    gap: 4px;
  }
  .hud {
    grid-template-columns: 31px repeat(3, 56px) 43px;
    gap: 3px;
    min-height: 0;
    justify-content: space-between;
    align-items: center;
  }
  .icon { width: 31px; min-height: 28px; font-size: 13px; }
  .hud-card { width: 56px; min-height: 28px; padding: 1px 2px; border-width: 2px; border-radius: 5px; }
  .hud-card span { font-size: 8px; white-space: nowrap; }
  .hud-card strong { font-size: 12px; }
  .soap-btn { width: 43px; min-height: 28px; padding: 1px 2px; font-size: 10px; white-space: nowrap; }
  .game-board { grid-template-rows: 36% 64%; }
  .customer-zone { grid-template-columns: repeat(3, 1fr); overflow: hidden; padding: 4px; gap: 4px; }
  .customer { grid-template-columns: 28px 1fr; gap: 2px; align-items: start; }
  .customer-slot.empty { min-height: 0; }
  .avatar { width: 28px; height: 28px; }
  .avatar img { left: -9px; top: -18px; width: 48px; height: 54px; }
  .bubble { min-height: 28px; padding: 2px; border-width: 2px; border-radius: 8px; font-size: 7px; line-height: 1.05; }
  .bubble small { font-size: 6px; margin-top: 0; }
  .customer-actions { margin-top: 1px; }
  .customer-actions button { min-height: 20px; padding: 0 5px; font-size: 8px; border-width: 2px; }
  .wait-bar { height: 7px; margin-top: 2px; border-width: 1px; }
  .wait-bar span { min-height: 100%; }
  .work-zone { grid-template-columns: 64px 1fr; }
  .item { width: 38px; height: 34px; }
  .item.on-belt .picture { width: 28px; height: 22px; }
  .picture { font-size: 28px; }
  .name-tag {
    left: 0;
    top: 25px;
    max-width: 48px;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 1px 2px;
    font-size: 7px;
  }
  .phone-panel {
    width: 86px;
    right: 5px;
    bottom: 5px;
    padding: 3px;
    border-width: 2px;
    border-radius: 10px;
  }
  .phone-top { font-size: 12px; margin-bottom: 4px; }
  .phone-list { max-height: 14px; padding: 1px; }
  .phone-row { height: 12px; min-height: 0; font-size: 3px; line-height: 1; padding: 0 1px; white-space: nowrap; overflow: hidden; }
  .phone-row span { display: none; }
  .phone-empty { display: block; height: 0; padding: 0; overflow: hidden; }
  .phone-display { height: 11px; margin: 1px 0; padding: 0; font-size: 6px; line-height: 11px; white-space: nowrap; border-radius: 5px; overflow: hidden; }
  .keypad { gap: 1px; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(4, 12px); }
  .keypad button { width: 100%; min-width: 0; height: 12px; min-height: 0; font-size: 6px; line-height: 1; border-radius: 3px; padding: 0; white-space: nowrap; overflow: hidden; border-width: 1px; box-shadow: none; display: grid; place-items: center; }
  .clean-stage { min-height: 300px; }
  .clean-preview { width: min(300px, 64vw); height: min(230px, 46vw); }
  .clean-progress { bottom: 10px; height: 10px; }
  .sponge { width: 56px; height: 40px; font-size: 22px; }
  .result-stats { grid-template-columns: 1fr; }
}

@media (min-width: 861px) and (max-width: 1180px) {
  .home.active {
    grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
  }
  .cover-image {
    object-fit: cover;
    object-position: 51% center;
    background: #112b33;
  }
  .home-panel {
    align-content: center;
    padding-top: clamp(18px, 4vh, 42px);
    padding-bottom: clamp(18px, 4vh, 42px);
  }
  .home-panel .cover-logo {
    width: min(280px, 92%);
  }
  .home-panel .cover-logo span {
    font-size: clamp(30px, 4.2vw, 44px);
  }
  .home-panel .cover-logo strong {
    font-size: clamp(20px, 2.8vw, 30px);
  }
}

@media (orientation: portrait) and (max-width: 1180px) {
  body.playing .rotate-tip {
    display: grid;
  }
}
