* {
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

body {
  margin: 0;
  height: 100vh;
  background: #fff9f0;
 font-family:
    -apple-system,
    BlinkMacSystemFont,
    "Hiragino Sans",
    "Yu Gothic",
    "Meiryo",
    sans-serif;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

.container {
  max-width: 1196px;
  width: 100%;
  height: 540px;
  position: relative;
}


#startScreen {
  width: 100%;
  height: 100%;
  background: linear-gradient(160deg, #fff5b8 0%, #ffd6e7 40%, #c8f0ff 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.deco {
  position: absolute;
  font-size: 52px;
  animation: float 3s ease-in-out infinite;
  user-select: none;
  pointer-events: none;
}

.deco:nth-child(1) {
  top: 20px;
  left: 60px;
  animation-delay: 0s;
}

.deco:nth-child(2) {
  top: 30px;
  right: 80px;
  animation-delay: .5s;
}

.deco:nth-child(3) {
  bottom: 40px;
  left: 100px;
  animation-delay: 1s;
}

.deco:nth-child(4) {
  bottom: 30px;
  right: 60px;
  animation-delay: 1.5s;
}

.deco:nth-child(5) {
  top: 180px;
  left: 30px;
  animation-delay: .8s;
  font-size: 40px;
}

.deco:nth-child(6) {
  top: 160px;
  right: 40px;
  animation-delay: 1.2s;
  font-size: 38px;
}

@keyframes float {

  0%,
  100% {
    transform: translateY(0) rotate(-5deg);
  }

  50% {
    transform: translateY(-14px) rotate(5deg);
  }
}

.title-box {
  text-align: center;
  z-index: 1;
}

.title-main {
  font-size: 72px;
  font-weight: 900;
  letter-spacing: 6px;
  color: #fff;
  text-shadow:
    3px 3px 0 #ff8ab5,
    6px 6px 0 #ffb347,
    -2px -2px 0 #a0d8ff;
  line-height: 1;
  margin-bottom: 8px;
}

.title-main-large {
  font-size: 76px;
}

.title-sub {
  font-size: 22px;
  color: #ff7ab0;
  font-weight: 700;
  letter-spacing: 4px;
  margin-bottom: 36px;
}

.start-btn {
  font-size: 32px;
  font-weight: 900;
  letter-spacing: 6px;
  color: #fff;
  background: linear-gradient(135deg, #ff7eb3 0%, #ff9d5c 100%);
  border: none;
  border-radius: 60px;
  padding: 18px 64px;
  cursor: pointer;
  box-shadow: 0 6px 0 #d45a5a, 0 8px 20px rgba(255, 120, 120, .35);
  transition: transform .1s, box-shadow .1s;
  position: relative;
  top: 0;
}

.start-btn:hover {
  background: linear-gradient(135deg, #ff5fa0 0%, #ff8840 100%);
}

.start-btn:active {
  top: 4px;
  box-shadow: 0 2px 0 #d45a5a, 0 4px 10px rgba(255, 120, 120, .2);
}


#gameScreen {
  width: 100%;
  height: 100%;
  background: linear-gradient(180deg, #e8f8ff 0%, #fff5fb 100%);
  display: none;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}


.game-header {
  height: 50px;
  flex-shrink: 0;
  background: linear-gradient(90deg, #ff9ede, #ffd76d, #8fd9ff);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, .12);
}

.game-title {
  font-size: 22px;
  font-weight: 900;
  color: #fff;
  text-shadow: 2px 2px 0 #ff6fa8;
  letter-spacing: 4px;
}

.header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.quit-btn {
  font-size: 16px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, #ff7eb3, #ff5c5c);
  border: none;
  border-radius: 30px;
  padding: 7px 20px;
  cursor: pointer;
  box-shadow: 0 4px 0 #c0394a;
  transition: transform .1s, box-shadow .1s;
  letter-spacing: 2px;
}

.quit-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #c0394a;
}

.header-undo-btn {
  font-size: 15px;
  font-weight: 800;
  color: #07577d;
  background: linear-gradient(135deg, #a8e6ff, #55bdf0);
  border: none;
  border-radius: 30px;
  padding: 7px 18px;
  cursor: pointer;
  box-shadow: 0 4px 0 #2784ad;
  letter-spacing: 1px;
  white-space: nowrap;
}

.header-undo-btn:disabled {
  cursor: default;
  filter: grayscale(.65);
  opacity: .45;
  box-shadow: none;
}

.header-undo-btn:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #2784ad;
}

.download-btn {
  font-size: 15px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, #7ce88a, #3dc95c);
  border: none;
  border-radius: 30px;
  padding: 7px 18px;
  cursor: pointer;
  box-shadow: 0 4px 0 #1e8c32;
  transition: transform .1s, box-shadow .1s;
  letter-spacing: 1px;
  white-space: nowrap;
}

.download-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #1e8c32;
}



.game-body {
  margin: 0;
  height: 100vh;
  background: #fff9f0;
  font-family: 'Hiragino Maru Gothic ProN', 'BIZ UDPGothic', 'Rounded Mplus 1c', sans-serif;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}


.canvas-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 8px 10px 10px;
  overflow: hidden;
}

#drawCanvas {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, .14), inset 0 0 0 3px #ffe0f0;
  cursor: crosshair;
  touch-action: none;
  display: block;
}


.tools-area {
  width: 196px;
  flex-shrink: 0;
  height: 100%;
  background: linear-gradient(180deg, #fff0fa 0%, #f0f9ff 100%);
  border-left: 3px solid #ffd6ee;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 10px;
  gap: 5px;
  overflow: hidden;
}


.current-color-box {
  width: 100%;
  flex-shrink: 0;
  border-radius: 12px;
  border: 3px solid #ffd6ee;
  background: #fff;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  padding: 5px 8px;
  gap: 8px;
}

.current-color-label {
  font-size: 12px;
  font-weight: 800;
  color: #bbb;
  letter-spacing: 1px;
  white-space: nowrap;
}

.current-color-preview {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid #eee;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .15);
  flex-shrink: 0;
}



.brush-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  width: 100%;
  flex-shrink: 0;
}

.brush-btn {
  background: #fff;
  border: 3px solid #ffc0dd;
  border-radius: 8px;
  cursor: pointer;
  padding: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color .15s, transform .1s;
  flex-shrink: 0;
  width: 100%;
  aspect-ratio: 1;
}

.brush-btn:hover {
  border-color: #ff7ab0;
  transform: scale(1.08);
}

.brush-btn.active {
  border-color: #ff3d85;
  background: #fff0f6;
}


.sep {
  width: 90%;
  flex-shrink: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, #ffd6ee, transparent);
  border-radius: 2px;
}


.tool-label {
  font-size: 12px;
  font-weight: 800;
  color: #ff7ab0;
  letter-spacing: 2px;
  align-self: flex-start;
  flex-shrink: 0;
}


.size-row {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: space-around;
  width: 100%;
  flex-shrink: 0;
}

.size-btn {
  background: #fff;
  border: 3px solid #ffc0dd;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: border-color .15s, transform .1s;
}

.size-btn-small,
.size-btn-medium {
  width: 34px;
  height: 34px;
}

.size-btn-large {
  width: 36px;
  height: 36px;
}

.size-btn-xlarge {
  width: 38px;
  height: 38px;
}

.size-btn:hover {
  border-color: #ff7ab0;
  transform: scale(1.1);
}

.size-btn.active {
  border-color: #ff3d85;
  background: #fff0f6;
}

.size-dot {
  border-radius: 50%;
  background: #555;
  display: block;
  pointer-events: none;
}

.size-dot-small {
  width: 6px;
  height: 6px;
}

.size-dot-medium {
  width: 12px;
  height: 12px;
}

.size-dot-large {
  width: 20px;
  height: 20px;
}

.size-dot-xlarge {
  width: 28px;
  height: 28px;
}


.color-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
  width: 100%;
  flex-shrink: 0;
}

.color-btn {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 8px;
  border: 3px solid transparent;
  cursor: pointer;
  transition: transform .1s, border-color .12s;
  box-shadow: 0 2px 4px rgba(0, 0, 0, .15);
}

.color-btn:hover {
  transform: scale(1.12);
}

.color-btn.active {
  border-color: #222;
  transform: scale(1.12);
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px #222;
}


.action-btns {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  flex-shrink: 0;
  margin-top: auto;
}

.action-btn {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 2px;
  border: none;
  border-radius: 30px;
  padding: 9px 0;
  cursor: pointer;
  width: 100%;
  transition: transform .1s, box-shadow .1s;
  flex-shrink: 0;
}

.action-btn:disabled {
  cursor: default;
  filter: grayscale(.65);
  opacity: .45;
  box-shadow: none;
}

.btn-undo {
  background: linear-gradient(135deg, #a8e6ff, #55bdf0);
  color: #07577d;
  box-shadow: 0 3px 0 #2784ad;
  font-size: 20px;
  line-height: 16px;
}

.btn-undo:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #2784ad;
}

.btn-eraser {
  background: linear-gradient(135deg, #ffe066, #ffc533);
  color: #7a4e00;
  box-shadow: 0 3px 0 #b87a00;
}

.btn-eraser:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #b87a00;
}

.btn-eraser.active {
  background: linear-gradient(135deg, #ffb300, #ff8f00);
}

.btn-clear {
  background: linear-gradient(135deg, #ff9090, #ff5252);
  color: #fff;
  box-shadow: 0 3px 0 #b81c1c;
}

.btn-clear:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #b81c1c;
}

.container {
  border: 2px solid #333;
  display: flex;
  flex-direction: column;
}

.game-main {
  position: relative;
  flex: 1;
  overflow: hidden;
}

.game-main #startScreen,
.game-main #gameScreen {
  position: absolute;
  inset: 0;
}

.download-confirm[hidden] {
  display: none;
}

.download-confirm {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(45, 35, 45, .5);
}

.download-confirm__panel {
  width: min(420px, 100%);
  padding: 26px 24px 22px;
  text-align: center;
  background: #fffdf8;
  border: 4px solid #b9efc2;
  border-radius: 24px;
  box-shadow: 0 12px 35px rgba(0, 0, 0, .25);
}

.download-confirm__icon {
  font-size: 44px;
  line-height: 1;
}

.download-confirm h2 {
  margin: 14px 0 8px;
  color: #333;
  font-size: 22px;
}

.download-confirm p {
  margin: 0 0 22px;
  color: #666;
  font-size: 15px;
}

.download-confirm__actions {
  display: flex;
  justify-content: center;
  gap: 12px;
}

.download-confirm__actions button {
  min-width: 130px;
  border: 0;
  border-radius: 30px;
  padding: 11px 18px;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
}

.download-confirm__cancel {
  order: 1;
  color: #555;
  background: #e9e9e9;
  box-shadow: 0 3px 0 #bdbdbd;
}

.download-confirm__save {
  order: 2;
  color: #fff;
  background: linear-gradient(135deg, #7ce88a, #3dc95c);
  box-shadow: 0 3px 0 #1e8c32;
}

.quit-confirm__quit {
  color: #fff;
  background: linear-gradient(135deg, #ff7e8e, #ff4f5f);
  box-shadow: 0 3px 0 #b52a38;
}

.download-confirm__actions button:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, .25);
}

@media (max-width: 480px) {
  .download-confirm__actions {
    flex-direction: column-reverse;
  }

  .download-confirm__actions button {
    width: 100%;
  }
}