﻿* {
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
:root {
  --yellow: #ffc93c;
  --orange: #ff8c42;
  --pink: #ff6f91;
  --blue: #3fa9f5;
  --green: #4cd787;
  --cream: #fff8ec;
  --ink: #4a3b2a;
}
html {
  margin: 0;
  height: 100%;
}
body {
  margin: 0;
  height: 100vh;
  font-family:
    -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", "Meiryo",
    sans-serif;
  background: #f2f2f2;
  display: flex;
  justify-content: center;
  align-items: center;
}
.container {
  position: relative;
  margin: 0 auto;
  background: #fff;
  border: 2px solid #333;
  width: 100%;
  max-width: 1196px;
  height: 540px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.game-header {
  position: absolute;
  inset: 0 0 auto;
  z-index: 10;
  height: 64px;
  padding: 6px 10px;
  background: transparent;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  border-bottom: 2px solid #ffe2ad;
}
.top-mode .game-header {
  display: none;
}
.game-header h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 900;
  color: var(--ink);
  text-align: center;
}
.header-info {
  display: flex;
  align-items: center;
  justify-self: start;
  width: max-content;
  gap: 8px;
  min-width: 110px;
  padding: 8px 18px;
  border-radius: 100px;
  background: var(--yellow);
  box-shadow: 0 4px 0 #e0a92c;
  color: #7a4b00;
  font-size: 22px;
  font-weight: 900;
  white-space: nowrap;
}
.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}
.quit-btn {
  padding: 12px 26px;
  border: 0;
  border-radius: 100px;
  background: linear-gradient(180deg, #8d8d97, #63636d);
  box-shadow: 0 5px 0 #0003;
  color: #fff;
  font-size: 18px;
  font-weight: 900;
  cursor: pointer;
}
.quit-btn:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 #0003;
}
.game-main {
  position: relative;
  background: var(--cream);
  flex: 1;
  overflow: hidden;
  display: grid;
  place-items: center;
}
.btn {
  padding: 12px 20px;
  font-size: 16px;
  border: 2px solid #333;
  background: #fff;
  cursor: pointer;
  border-radius: 10px;
  transition:
    background-color 0.15s ease,
    transform 0.05s ease;
}
.btn:hover {
  background: #d6f0ff;
}
.btn:active {
  transform: scale(0.98);
}
.sound-btn {
  position: relative;
  width: 82px;
  height: 44px;
  padding: 4px 34px 4px 12px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(180deg, #78adff, #5588f2);
  box-shadow: 0 4px 0 #376bd1;
  color: #fff;
  font-size: 17px;
  line-height: 1;
}
.sound-btn::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 13px;
  width: 16px;
  height: 16px;
  border: 1.5px solid #fff;
  border-radius: 50%;
  transform: translateY(-50%);
}
.sound-btn[aria-pressed=false]::after {
  content: '×';
  border: 0;
  font-size: 24px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}
.sound-btn:hover {
  background: linear-gradient(180deg, #8bb9ff, #6696f6);
}
.sound-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #376bd1;
}
.top-sound {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 5;
}
.deco {
  position: absolute;
  border-radius: 50%;
  opacity: 0.35;
}
.d1 {
  width: 160px;
  height: 160px;
  background: var(--yellow);
  top: -60px;
  left: -40px;
}
.d2 {
  width: 120px;
  height: 120px;
  background: var(--blue);
  bottom: -40px;
  right: 60px;
}
.d3 {
  width: 90px;
  height: 90px;
  background: var(--pink);
  top: 40%;
  right: -30px;
}
.d4 {
  width: 70px;
  height: 70px;
  background: var(--green);
  bottom: 20px;
  left: 20px;
}
.screen {
  position: absolute;
  inset: 0;
  display: none;
  z-index: 1;
}
.screen.active {
  display: flex;
}
.container:not(.top-mode) .screen {
  padding-top: 64px;
}
.start-screen {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 20px;
  text-align: center;
}
.title-card {
  background: #fff;
  border-radius: 26px;
  padding: 20px 36px;
  box-shadow: 0 8px 0 #f1e2bd;
  border: 4px dashed var(--orange);
}
.title-emoji {
  font-size: 52px;
}
.title-text {
  margin: 0;
  color: var(--ink);
  font-size: 32px;
  font-weight: 900;
  letter-spacing: 2px;
}
.title-sub {
  margin: 8px 0 0;
  color: #8a7a5c;
}
.preview-row {
  font-size: 38px;
  word-spacing: 8px;
}
.big-btn {
  min-width: 220px;
  padding: 17px 48px;
  border: 0;
  border-radius: 100px;
  background: linear-gradient(180deg, #ffd85b, #ffad32);
  box-shadow:
    0 6px 0 #d77b16,
    0 10px 18px #d77b1638;
  color: #6c3d00;
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 2px;
  text-shadow: 0 1px #fff8;
  transition:
    transform 0.12s ease,
    box-shadow 0.12s ease,
    filter 0.15s ease;
}
.big-btn:hover {
  background: linear-gradient(180deg, #ffe477, #ffb942);
  filter: saturate(1.08);
}
.big-btn:active {
  transform: translateY(5px);
  box-shadow:
    0 1px 0 #d77b16,
    0 4px 8px #d77b1628;
}
.game-screen {
  flex-direction: column;
}
.play-area {
  flex: 1;
  min-height: 0;
  display: flex;
}
.shop {
  width: 270px;
  flex: 0 0 270px;
  display: flex;
  flex-direction: column;
  padding: 10px 10px 14px;
}
.veg {
  background: linear-gradient(#ffe8c2, #ffd9a0);
}
.fruit {
  background: linear-gradient(#ffd3e4, #ffb9d3);
}
.awning {
  height: 22px;
  margin: -10px -10px 8px;
  border-radius: 6px 6px 0 0;
  background-color: var(--orange);
  background-image: repeating-linear-gradient(
    90deg,
    #fff 0 20px,
    transparent 20px 40px
  );
}
.fruit .awning {
  background-color: var(--pink);
}
.shop-label {
  margin-bottom: 8px;
  padding: 6px 4px;
  background: #ffffffcc;
  border-radius: 14px;
  text-align: center;
  font-size: 20px;
  font-weight: 900;
}
.drop-zone {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: min-content;
  align-content: start;
  gap: 8px;
  padding: 10px;
  border: 4px dashed #ffffffaa;
  border-radius: 16px;
  background: #ffffff55;
}
.pool-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 14px;
}
.pool-title {
  text-align: center;
  margin-bottom: 8px;
  color: #8a7654;
  font-weight: 700;
}
.pool {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  align-content: center;
  justify-content: center;
  gap: 18px;
}
.item-card {
  width: 138px;
  height: 126px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #fff;
  border: 3px solid #ffe9c2;
  border-radius: 20px;
  box-shadow: 0 5px 0 #0002;
  cursor: grab;
  touch-action: none;
}
.emoji {
  font-size: 50px;
}
.name {
  margin-top: 6px;
  color: var(--ink);
  font-size: 15px;
  font-weight: 900;
}
.item-card.dragging {
  position: fixed;
  z-index: 50;
  box-shadow: 0 12px 20px #0004;
}
.placed-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6px 2px;
  background: #fff;
  border-radius: 12px;
  animation: pop 0.35s;
}
.placed-item .emoji {
  font-size: 26px;
}
.placed-item .name {
  font-size: 11px;
}
.shake {
  animation: shake 0.4s;
}
.confetti {
  position: fixed;
  z-index: 100;
  width: 10px;
  height: 16px;
  border-radius: 2px;
  pointer-events: none;
  animation: confetti-burst 0.85s cubic-bezier(0.15, 0.7, 0.35, 1) forwards;
}
.toast {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 60;
  padding: 16px 34px;
  border-radius: 20px;
  background: #3c2814e6;
  color: #fff;
  font-size: 28px;
  font-weight: 900;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.7);
  transition: 0.15s;
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}
.toast.ok {
  background: #1e9650eb;
}
.toast.ng {
  background: #dc4646eb;
}
.result-screen {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  text-align: center;
}
.result-card {
  padding: 30px 46px;
  background: #fff;
  border: 4px solid var(--green);
  border-radius: 26px;
  box-shadow: 0 8px 0 #f1e2bd;
}
.result-emoji {
  font-size: 56px;
}
.result-text {
  margin: 10px 0 0;
  color: var(--ink);
  font-size: 30px;
  font-weight: 900;
}
.result-text span {
  color: var(--pink);
  font-size: 36px;
}
.result-btns {
  display: flex;
  gap: 18px;
}
.result-btns .btn {
  min-width: 160px;
  padding: 14px 26px;
  border: 0;
  font-size: 18px;
  font-weight: 900;
  border-radius: 100px;
  transition:
    transform 0.12s ease,
    box-shadow 0.12s ease,
    filter 0.15s ease;
}
#retryBtn {
  background: linear-gradient(180deg, #ffd85b, #ffad32);
  box-shadow: 0 5px 0 #d77b16;
  color: #6c3d00;
}
#retryBtn:hover {
  background: linear-gradient(180deg, #ffe477, #ffb942);
}
#homeBtn {
  background: linear-gradient(180deg, #78adff, #5588f2);
  box-shadow: 0 5px 0 #376bd1;
  color: #fff;
}
#homeBtn:hover {
  background: linear-gradient(180deg, #8bb9ff, #6696f6);
}
.result-btns .btn:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 #0003;
}
.new-record {
  display: none;
  margin: 12px 0 0;
  padding: 7px 14px;
  border-radius: 100px;
  background: #fff0b8;
  color: #e47712;
  font-size: 17px;
  font-weight: 900;
  animation: pop 0.45s;
}
.new-record.show {
  display: block;
}
@keyframes pop {
  0% {
    transform: scale(0.3);
    opacity: 0;
  }
  60% {
    transform: scale(1.15);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}
@keyframes shake {
  25% {
    transform: translateX(-10px);
  }
  50% {
    transform: translateX(10px);
  }
  75% {
    transform: translateX(-8px);
  }
}
@keyframes confetti-burst {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) rotate(0);
  }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--x)), calc(-50% + var(--y)))
      rotate(var(--r));
  }
}
@media (max-width: 700px) {
  .game-header {
    grid-template-columns: auto 1fr auto;
    gap: 5px;
    padding-inline: 6px;
  }
  .game-header h1 {
    font-size: 14px;
  }
  .header-info {
    font-size: 12px;
  }
  .header-actions {
    gap: 3px;
  }
  .header-actions .btn {
    padding: 7px 8px;
    font-size: 13px;
  }
  .header-actions .sound-btn {
    width: 72px;
    height: 40px;
    padding: 4px 30px 4px 10px;
  }
  .header-actions .sound-btn::after {
    right: 10px;
    width: 14px;
    height: 14px;
  }
  .shop {
    width: 130px;
    flex-basis: 130px;
  }
  .drop-zone {
    grid-template-columns: repeat(2, 1fr);
    gap: 5px;
    padding: 5px;
  }
  .pool-wrap {
    padding: 8px 5px;
  }
  .pool {
    gap: 8px;
  }
  .item-card {
    width: 70px;
    height: 70px;
  }
  .item-card .emoji {
    font-size: 29px;
  }
  .item-card .name {
    font-size: 10px;
  }
  .title-text {
    font-size: 24px;
  }
  .title-card {
    padding-inline: 18px;
  }
}
