/* 2048 版: vedia_kilo-cli_nvidia-nemotron-3.5-super-vl 専用スタイル */

.k323 {
  display: block !important;
}
.k323-hidden {
  display: none !important;
}

body:has(.k323) {
  background: linear-gradient(135deg, #2d3436 0%, #1e272e 100%);
  background-repeat: no-repeat;
  background-attachment: fixed;
  color: #f5f6fa;
}
body:has(.k323) > main {
  padding: 0;
  background: transparent;
}

.k323-game-header {
  text-align: center;
  padding: 8px 12px 4px;
}

.k323-title {
  margin: 0;
  font-size: 2rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #ffd93d;
  text-shadow: 0 2px 4px rgba(0,0,0,0.4);
}

.k323-scoreboard {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin: 8px 0 12px;
}

.k323-score-item {
  text-align: center;
}

.k323-score-label {
  display: block;
  font-size: 0.8rem;
  color: #b2bec3;
  margin-bottom: 2px;
}

.k323-score-value {
  display: inline-block;
  min-width: 56px;
  font-size: 1.35rem;
  font-weight: bold;
  color: #ffd93d;
  padding: 4px 10px;
  border-radius: 8px;
  background: rgba(0,0,0,0.35);
}

.k323-stage {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  padding: 8px 12px 8px;
  box-sizing: border-box;
  min-height: var(--yz-stage-h);
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
}

.k323-grid {
  position: relative;
  width: min(92vw, calc(var(--yz-stage-h) - 170px));
  height: min(92vw, calc(var(--yz-stage-h) - 170px));
  max-width: 380px;
  max-height: 380px;
  background: #bbada0;
  border-radius: 8px;
  padding: 10px;
  box-sizing: border-box;
  touch-action: none;
  user-select: none;
  overflow: hidden;
}

.k323-cell {
  position: absolute;
  width: calc(25% - 10px);
  height: calc(25% - 10px);
  background: #cdc1b4;
  border-radius: 4px;
  box-sizing: border-box;
}

.k323-tile {
  position: absolute;
  width: calc(25% - 10px);
  height: calc(25% - 10px);
  border-radius: 4px;
  background: #eee4da;
  color: #776e65;
  font-weight: bold;
  font-size: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  transition: transform 0.18s ease, opacity 0.18s ease, background 0.1s ease;
  will-change: transform;
  overflow: hidden;
}

.k323-tile.merged {
  font-size: 1.6rem;
  transform: scale(1.05);
}

.k323-tile.new {
  transform: scale(0.6);
  opacity: 0.7;
}

.k323-message {
  margin-top: 12px;
  text-align: center;
  min-height: 44px;
}

.k323-message.k323-show {
  animation: k323-message-in 0.3s ease;
}

.k323-message-text {
  display: inline-block;
  padding: 10px 20px;
  border-radius: 30px;
  font-size: 1.5rem;
  font-weight: bold;
  color: #fff;
}

.k323-message-clear .k323-message-text {
  background: #8e44ad;
}

.k323-message-over .k323-message-text {
  background: #c0392b;
}

.k323-game-footer {
  text-align: center;
  padding: 12px 12px 20px;
}

.k323-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 130px;
  height: 48px;
  padding: 0 24px;
  border: none;
  border-radius: 30px;
  background: #ffd93d;
  color: #2d3436;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
  touch-action: manipulation;
}

.k323-btn:active {
  transform: scale(0.96);
}

@keyframes k323-message-in {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* スマホ向け最適化（幅 600px 以下） */
@media (max-width: 600px) {
  .k323-title { font-size: 1.7rem; }
  .k323-score-value { font-size: 1.25rem; min-width: 52px; }
  .k323-scoreboard { gap: 16px; margin: 6px 0 10px; }
  .k323-stage { padding: 6px 8px 6px; }
  .k323-grid { width: min(94vw, calc(var(--yz-stage-h) - 150px)); height: min(94vw, calc(var(--yz-stage-h) - 150px)); max-width: 340px; max-height: 340px; padding: 8px; }
  .k323-tile { font-size: 1.6rem; }
  .k323-btn { height: 46px; min-width: 120px; padding: 0 18px; font-size: 0.95rem; }
  .k323-message-text { font-size: 1.25rem; padding: 8px 16px; }
  .k323-game-footer { padding: 10px 8px 18px; }
}

/* prefers-reduced-motion: アニメーションを控える */
@media (prefers-reduced-motion: reduce) {
  .k323-tile {
    transition: none;
  }
  .k323-message.k323-show {
    animation: none;
  }
  .k323-tile.new {
    transform: none;
    opacity: 1;
  }
  .k323-tile.merged {
    transform: none;
  }
}
