:root{font-family:'Malgun Gothic','Apple SD Gothic Neo',system-ui,sans-serif;color:#294b47;background:#fbf6eb;font-synthesis:none;--teal:#267c75;--primary:#267c75;--muted:#73837a;--line:#e2dccb;--text:#294b47}
*{box-sizing:border-box}body{margin:0;background:radial-gradient(ellipse at 0 0,#f8e8ca,transparent 55%),#fbf6eb}button,input,select,textarea{font:inherit}button{cursor:pointer;touch-action:manipulation}button:disabled{cursor:not-allowed;opacity:.55}button:focus-visible,a:focus-visible,input:focus-visible,textarea:focus-visible,select:focus-visible{outline:3px solid #e5a365;outline-offset:4px}[hidden]{display:none!important}.sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0);clip-path:inset(50%);white-space:nowrap}
.app-shell {
  display:flex;
  flex-direction:column;
  height:100dvh;
  padding:4px 8px 6px;
}
.header {
  display:grid;
  grid-template-columns:minmax(0,1fr) auto minmax(0,1fr);
  align-items:center;
  gap:10px;
  flex:none;
  min-height:44px;
  margin-bottom:5px;
  padding:0 4px;
}
#gameTitle {
  min-width:0;
  margin:0;
  overflow:hidden;
  white-space:nowrap;
  text-overflow:ellipsis;
  font-size:clamp(18px,1.55vw,25px);
  line-height:1.15;
  letter-spacing:-.045em;
}
.header-tools { justify-self:end; display:flex; align-items:center; gap:5px; }
.tool {
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:5px;
  height:36px;
  padding:0 11px;
  border:1px solid #dcdaca;
  border-radius:11px;
  background:#fff;
  color:#4d6b62;
  font-size:13px;
  font-weight:700;
}
.tool>span:first-child { font-size:19px; line-height:1; }
.tool.settings { background:#e4ede2; color:#316f64; border-color:#cfdcc9; }
.tool:hover { background:#e7eddd; }
.workspace { display:flex; flex:1; min-height:0; }
.playground {
  position:relative;
  width:100%;
  min-height:0;
  overflow:hidden;
  border:1px solid #d8d2bc;
  border-radius:18px;
  background:#fffaf0;
}
.art-area { position:absolute; inset:3px; overflow:hidden; border-radius:14px; }
.stage-art { position:relative; width:100%; height:100%; container-type:size; }
#scene { position:absolute; inset:0; overflow:hidden; }
.model-canvas { width:100%; height:100%; display:block; }
.capsule-count,.stage-speed { position:absolute; right:14px; z-index:2; pointer-events:none; }
.capsule-count { top:12px; padding:4px 9px; border:1px solid #d7d9c6; border-radius:30px; background:#ffffffe0; color:#4f7467; font-size:12px; }
.stage-speed { bottom:11px; color:#657367; font-size:11px; }
.controls,.play-actions { display:flex; align-items:center; justify-content:center; gap:6px; min-width:0; }
.app-shell:not(.is-playing) .play-actions { display:none; }
.draw-button {
  display:flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  width:clamp(150px,17vw,240px);
  min-width:0;
  min-height:41px;
  padding:4px 15px;
  border:1px solid #bb622c;
  border-radius:12px;
  background:linear-gradient(135deg,#de8e4d,#c66e34);
  box-shadow:0 2px 0 #9c4e26;
  color:#fff;
  font-size:18px;
  font-weight:800;
  letter-spacing:-.035em;
  transition:filter .2s,transform .1s;
}
.draw-button:hover { filter:brightness(1.06); }
.draw-button:active { transform:translateY(2px); box-shadow:none; }
.draw-icon { font-size:23px; font-weight:400; line-height:1; }
#drawText { min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.secondary,.primary { min-height:40px; padding:8px 13px; border-radius:11px; font-weight:700; font-size:13px; white-space:nowrap; }
.secondary { color:#54786b; border:1px solid #d9ddcc; background:#ffffffd9; }
.primary { border:0; background:#287d76; color:#fff; }
.is-playing .draw-button { font-size:16px; }
.result-card {
  position:absolute;
  z-index:4;
  left:50%;
  top:49%;
  transform:translate(-50%,-50%);
  width:min(70cqw,1000px);
  height:clamp(300px,55cqh,480px);
  max-height:80%;
  display:grid;
  align-items:safe center;
  padding:clamp(22px,4cqh,44px) clamp(28px,3.4cqw,60px);
  overflow:auto;
  overscroll-behavior:contain;
  border:2px solid #dfc79b;
  border-radius:clamp(22px,2.2cqw,34px);
  background:linear-gradient(145deg,#fff9e9,#fffefa 75%);
  box-shadow:0 6px 0 #dfcba74d,0 16px 48px #425e4229;
  text-align:center;
  animation:resultIn .4s ease-out;
}
/* Keep the empty card measurable so the halves clear its edges before the reveal. */
.result-card[hidden] {
  display:grid!important;
  visibility:hidden;
  pointer-events:none;
  animation:none;
}
.result-layout,.result-copy { display:grid; align-items:center; min-width:0; }
.result-layout { gap:clamp(18px,2.6cqw,44px); }
.result-layout:has(> img:not([hidden])) { grid-template-columns:auto minmax(0,1fr); }
.result-copy { justify-items:center; gap:clamp(9px,1.8cqh,18px); }
.result-copy::before { content:""; width:clamp(46px,5cqw,80px); height:5px; border-radius:9px; background:#df9a59; }
#resultHeading { margin:0; max-width:100%; font-size:clamp(16px,1.5cqw,24px); letter-spacing:.07em; color:#8d5d33; font-weight:700; overflow-wrap:anywhere; }
#resultName {
  max-width:100%;
  margin:0;
  font-size:clamp(62px,8.8cqw,128px);
  line-height:1.13;
  letter-spacing:-.045em;
  color:#20685f;
  white-space:pre-wrap;
  overflow-wrap:anywhere;
}
#resultName[data-length="medium"] { font-size:clamp(40px,4.6cqw,76px); }
#resultName[data-length="long"] { font-size:clamp(30px,3.2cqw,54px); }
#resultPhoto {
  width:min(19cqw,34cqh,270px);
  aspect-ratio:1;
  height:auto;
  object-fit:cover;
  border:clamp(4px,.4cqw,7px) solid #f5dfb8;
  border-radius:clamp(18px,2cqw,32px);
  justify-self:center;
}
#resultMission {
  max-width:100%;
  padding:.52em .9em;
  background:#eaf0e3;
  border-radius:16px;
  font-size:clamp(20px,1.85cqw,31px);
  line-height:1.48;
  white-space:pre-wrap;
  overflow-wrap:anywhere;
  color:#405e50;
}
.result-spark { color:#d49a44; font-size:clamp(18px,1.8cqw,28px); line-height:1; }
@container (max-width:680px) {
  .result-card { width:92%; height:clamp(300px,65cqh,500px); max-height:74%; padding:clamp(16px,3cqh,28px) clamp(16px,4.5cqw,28px); }
  .result-layout:has(> img:not([hidden])) { grid-template-columns:minmax(0,1fr); }
  .result-layout { gap:clamp(12px,2.5cqh,20px); }
  .result-copy { gap:clamp(8px,1.7cqh,14px); }
  #resultName { font-size:clamp(46px,15.5cqw,78px); }
  #resultName[data-length="medium"] { font-size:clamp(33px,9cqw,52px); }
  #resultName[data-length="long"] { font-size:clamp(26px,7cqw,38px); }
  #resultPhoto { width:min(41cqw,26cqh,175px); }
  #resultMission { font-size:clamp(17px,4.6cqw,23px); }
}
.pause-overlay{position:absolute;inset:0;z-index:6;display:flex;flex-direction:column;justify-content:center;align-items:center;background:#fff9eae8;backdrop-filter:blur(5px);color:#4e7767}.pause-overlay>span{font-size:42px;font-weight:800;color:#df9b5b}.pause-overlay h2{font-size:24px;margin:15px 0 0}.pause-overlay p{font-size:13px;margin-bottom:25px}.pause-overlay button{padding:15px 28px;font-size:16px}
.sound-panel{position:fixed;z-index:20;right:10px;top:50px;width:min(280px,calc(100vw - 12px));background:#fff;border:1px solid #dcd8c1;border-radius:22px;padding:20px;box-shadow:0 18px 60px #314e3826}.sound-heading{display:flex;align-items:center;justify-content:space-between;font-size:14px}.sound-heading button{width:32px;height:32px;border:0;background:#edf0df;border-radius:50%;color:#617d69;font-size:22px}.sound-panel label{display:grid;gap:10px;border-top:1px solid #e8e8d6;padding-top:15px;margin-top:15px;font-size:14px}.sound-panel input{accent-color:#287d76}.sound-panel small{font-size:10px;color:#6f826e}.sound-panel>p{font-size:10px;color:#78846d;margin-bottom:0}.notice{position:fixed;bottom:22px;left:50%;transform:translateX(-50%);z-index:100;padding:13px 22px;border-radius:14px;background:#315e51;color:white;font-size:13px;max-width:90vw;box-shadow:0 9px 25px #254c3426}.confetti-piece{position:absolute;top:40%;left:50%;width:8px;height:14px;border-radius:2px;animation:celebrate 1.7s cubic-bezier(.1,.6,.3,1) both;pointer-events:none}#confetti{position:absolute;inset:0;z-index:5;overflow:hidden;pointer-events:none}@keyframes celebrate{from{opacity:1;transform:translate(0,0) rotate(0)}to{opacity:0;transform:translate(var(--x),var(--y)) rotate(var(--r))}}@keyframes resultIn{from{opacity:0;transform:translate(-50%,-50%) scale(.96)}to{opacity:1;transform:translate(-50%,-50%) scale(1)}}:fullscreen{background:#fbf6eb}.expanded-view{position:fixed;inset:0;z-index:15;overflow:auto;background:#fbf6eb}
@media (max-width:800px) {
  .header-tools { gap:3px; }
  .tool { width:37px; height:40px; padding:0; }
  .tool-text { display:none; }
}
@media (max-width:660px) {
  .app-shell { padding:4px 4px 5px; }
  .header { gap:4px; padding:0; margin-bottom:3px; }
  #gameTitle {
    display:-webkit-box;
    -webkit-line-clamp:2;
    -webkit-box-orient:vertical;
    white-space:normal;
    overflow-wrap:anywhere;
    font-size:clamp(14px,3.5vw,19px);
    line-height:1.2;
  }
  .controls { width:clamp(103px,30vw,170px); }
  .draw-button { width:100%; min-height:40px; padding:3px 6px; gap:5px; font-size:16px; }
  .draw-icon { font-size:20px; }
  .header-tools { gap:2px; }
  .tool { width:clamp(32px,9vw,38px); }
  .is-playing .draw-button { display:none; }
  .play-actions { width:100%; gap:3px; }
  .play-actions .secondary { min-height:40px; padding:4px 6px; font-size:12px; }
  .playground { border-radius:14px; }
  .art-area { inset:2px; border-radius:11px; }
  .capsule-count,.stage-speed { right:9px; }
  .capsule-count { top:8px; font-size:11px; }
  .stage-speed { bottom:8px; font-size:10px; }
  .sound-panel { right:5px; }
  .pause-overlay h2 { font-size:21px; }
}
@media (max-width:360px) {
  .header-tools { gap:1px; }
  .tool { width:30px; }
  .draw-icon { display:none; }
  .play-actions .secondary { padding-inline:4px; }
}
@media(prefers-reduced-motion:reduce){*{animation-duration:.01ms!important;transition:none!important}}.reduce-motion .confetti-piece{display:none}.reduce-motion .result-card{animation:none}

.game-identity { min-width: 0; }
.collection-link {
  display: inline-block;
  color: #225e58;
  font-size: 0.8125rem;
  font-weight: 700;
  line-height: 1.45;
  text-decoration: underline;
  text-underline-offset: 0.18em;
}
.collection-link:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}
