/* ============================
   CSS Variables & Base Styles
   カラーパレットは theme.css (共有) で定義。
   ============================ */

/* Reset & Base */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Noto Sans JP', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  height: calc(var(--vh, 1vh) * 100);
  min-height: -webkit-fill-available;
  overflow-y: auto;
  overflow-x: hidden;
  line-height: 1.6;
}

/* ============================
   Screen System
   ============================ */
.screen {
  display: none;
  height: calc(var(--vh, 1vh) * 100);
  height: calc(var(--vh, 1vh) * 100);
  overflow-y: auto;
  overflow-x: hidden;
}

.screen.active {
  display: flex;
}

/* 非表示画面のアニメーションを停止（GPU負荷軽減） */
.screen:not(.active) * {
  animation-play-state: paused !important;
}

/* ============================
   Top Screen
   ============================ */
.top-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(var(--vh, 1vh) * 100);
  width: 100%;
  padding: 2rem;
  background: var(--bg-primary);
}

.top-hero {
  text-align: center;
  margin-bottom: 3rem;
  animation: fadeInUp 0.8s ease-out;
  color: var(--text-primary);
}

/* Logo tiles animation */
.logo-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.logo-tiles {
  display: flex;
  gap: 6px;
  margin-bottom: 0.5rem;
}

.logo-tile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 60px;
  border-radius: var(--radius-sm);
  font-size: 1.5rem;
  font-weight: 900;
  color: #333;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.4) 0%, transparent 40%, rgba(0, 0, 0, 0.1) 100%),
    linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.02) 2px, transparent 4px),
    #e8d5b5;
  border: 1px solid #d0ba96;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3), inset 0 2px 4px rgba(255, 255, 255, 0.8);
  animation: tileFloat 3s ease-in-out infinite;
  position: relative;
  overflow: hidden;
}

.logo-tile::after {
  content: '';
  position: absolute;
  top: 0;
  left: -50%;
  width: 200%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
  animation: shimmer 4s ease-in-out infinite;
}

.logo-tile.red {
  color: #d32f2f;
  animation-delay: 0s;
}

.logo-tile.blue {
  color: #1976d2;
  animation-delay: 0.1s;
}

.logo-tile.orange {
  color: #f57c00;
  animation-delay: 0.2s;
}

.logo-tile.black {
  color: #212121;
  animation-delay: 0.3s;
}

.app-title {
  font-size: 2.2rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  line-height: 1.3;
}

.title-accent {
  display: block;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent-primary);
  letter-spacing: 0.15em;
}

.app-subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-top: 0.5rem;
  letter-spacing: 0.1em;
}

/* Mode selection buttons */
.mode-selection {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
  max-width: 420px;
  animation: fadeInUp 0.8s ease-out 0.2s both;
}

.mode-btn {
  display: flex;
  align-items: center;
  gap: 1.2rem;
  width: 100%;
  padding: 1.3rem 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: transform var(--transition-smooth), background-color var(--transition-smooth), border-color var(--transition-smooth), box-shadow var(--transition-smooth);
  text-align: left;
  position: relative;
  overflow: hidden;
}

.mode-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  border-radius: 4px 0 0 4px;
  transition: width var(--transition-fast);
}

.practice-btn::before {
  background: var(--accent-primary);
}

.reproduce-btn::before {
  background: var(--accent-secondary);
}

.build-btn::before {
  background: #66bb6a;
}

.mode-btn:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.12);
  transform: translateX(4px);
  box-shadow: var(--shadow-md);
}

.mode-btn:hover::before {
  width: 6px;
}

.mode-btn:active {
  transform: translateX(2px) scale(0.99);
}

.mode-btn-icon {
  font-size: 2rem;
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border-radius: var(--radius-sm);
}

.mode-btn-text {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.mode-btn-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.mode-btn-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

/* Footer */
.top-footer {
  margin-top: 3rem;
  color: var(--text-muted);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  animation: fadeInUp 0.8s ease-out 0.4s both;
  text-align: center;
}

.top-footer a:hover {
  color: var(--accent-primary) !important;
  text-decoration: none !important;
}

/* 言語選択ボタン */
.lang-selection {
  margin-top: 1.5rem;
  display: flex;
  gap: 0.8rem;
  justify-content: center;
}

.lang-btn {
  padding: 0.5rem 1.2rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  backdrop-filter: blur(4px);
}

.lang-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  color: var(--text-primary);
}

.lang-btn.active {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #ffffff;
  box-shadow: none;
}

/* ============================
   Modal Overlay
   ============================ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.7);
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

#modal-notify {
  z-index: 3000;
}

.modal-overlay.active {
  display: flex;
  animation: fadeIn 0.25s ease-out;
}

.modal-dialog {
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 2rem;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
  animation: modalSlideUp 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-heading {
  font-size: 1.3rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 1.8rem;
  color: var(--text-primary);
  letter-spacing: 0.05em;
}

.modal-body {
  margin-bottom: 2rem;
}

/* Setting row */
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.2rem;
  background: var(--surface);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.setting-label {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  cursor: pointer;
}

.setting-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}

.setting-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
  transition: color var(--transition-fast);
}

/* Set count options */
.set-count-options {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  width: 100%;
}

.set-count-btn {
  flex: 1;
  min-width: 40px;
  padding: 0.4rem 0.6rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
  text-align: center;
}

.set-count-btn:hover {
  background: var(--surface-light);
  color: var(--text-primary);
}

.set-count-btn.active {
  background: var(--accent-primary);
  color: #fff;
  border-color: var(--accent-primary);
  box-shadow: 0 2px 8px rgba(79, 195, 247, 0.3);
}

/* Toggle switch */
.toggle-switch {
  position: relative;
  flex-shrink: 0;
}

.toggle-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-track {
  display: block;
  width: 52px;
  height: 28px;
  background: #c8cfd8;
  border-radius: 30px;
  position: relative;
  transition: background-color var(--transition-fast);
  cursor: pointer;
}

.toggle-thumb {
  display: block;
  width: 22px;
  height: 22px;
  background: #fff;
  border-radius: 50%;
  position: absolute;
  top: 3px;
  left: 3px;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  box-shadow: 0 2px 5px rgba(27, 94, 32, 0.2);
}

.toggle-input:checked+.toggle-track {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
}

.toggle-input:checked+.toggle-track .toggle-thumb {
  transform: translateX(24px);
  background: #fff;
}

.toggle-input:focus-visible+.toggle-track {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

/* Modal actions */
.modal-actions {
  display: flex;
  gap: 0.8rem;
}

.btn-primary,
.btn-secondary {
  flex: 1;
  padding: 0.85rem 1.2rem;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform var(--transition-fast), background-color var(--transition-fast), box-shadow var(--transition-fast);
  border: none;
  letter-spacing: 0.03em;
}

.btn-primary {
  background: var(--accent-primary);
  color: #fffef9;
  border: 2px solid var(--accent-primary);
  border-radius: var(--radius-sm);
  letter-spacing: 0.05em;
  font-weight: 800;
  box-shadow: none;
}

.btn-primary:hover {
  transform: translateY(-1px);
  background: var(--accent-primary-hover);
  border-color: var(--accent-primary-hover);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

.btn-secondary:hover {
  background: var(--surface-light);
  color: var(--text-primary);
}

/* ============================
   Play Screen
   ============================ */
.build-container {
  width: 100%;
  height: calc(var(--vh, 1vh) * 100);
  height: calc(var(--vh, 1vh) * 100);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
}

.play-container {
  width: 100%;
  height: calc(var(--vh, 1vh) * 100);
  height: calc(var(--vh, 1vh) * 100);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
}

.play-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1rem;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
  z-index: 10;
}

.play-header-center {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.play-header-right {
  width: 120px;
}

.btn-back {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.8rem;
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.btn-back:hover {
  background: var(--surface-light);
  color: var(--text-primary);
}

.back-arrow {
  font-size: 1rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.7rem;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.badge.joker-on {
  background: transparent;
  color: var(--accent-secondary);
  border: 1.5px solid var(--accent-secondary);
}

.badge.joker-off {
  background: transparent;
  color: var(--text-secondary);
  border: 1.5px solid #7a8290;
}

.stock-badge {
  background: var(--accent-primary);
  color: #fffef9;
  border: 1.5px solid var(--accent-primary);
}

/* ============================
   Tiles
   ============================ */
.tile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 48px;
  border-radius: 5px;
  font-size: 1.1rem;
  font-weight: 800;
  color: #333;
  cursor: grab;
  user-select: none;
  position: relative;
  flex-shrink: 0;
  background-color: #e8d5b5;
  border: 1px solid #c9bda8;
}

.tile:hover {
  z-index: 5;
}

.tile:active {
  cursor: grabbing;
}

.tile.dragging {
  opacity: 0.4;
}

/* Tile colors */
.tile.tile-red {
  color: #d32f2f;
}

.tile.tile-blue {
  color: #1976d2;
}

.tile.tile-black {
  color: #212121;
}

.tile.tile-orange {
  color: #f57c00;
}

.tile.tile-joker {
  color: #7b1fa2;
  font-size: 1.4rem;
}

/* Selected tile highlight */
.tile.selected {
  outline: 2.5px solid #fdd835;
  outline-offset: 1px;
  z-index: 5;
}

/* Selection rectangle */
.selection-rect {
  position: fixed;
  border: 2px dashed rgba(79, 195, 247, 0.7);
  background: rgba(79, 195, 247, 0.1);
  pointer-events: none;
  z-index: 9999;
  border-radius: 3px;
}

/* Drag ghost for multiple tiles */
.drag-ghost {
  position: fixed;
  top: -9999px;
  left: -9999px;
  display: flex;
  gap: 2px;
  background: rgba(15, 25, 35, 0.7);
  border-radius: 6px;
  z-index: 99999;
  pointer-events: none !important;
  will-change: transform;
}

.ghost-tile {
  box-shadow: none !important;
  transition: none !important;
  transform: none !important;
  opacity: 0.9 !important;
}

/* ============================
   Field Area
   ============================ */
.field-area {
  flex: 1;
  padding: 0.8rem;
  overflow-y: scroll;
  min-height: 0;
}

.field-sets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: flex-start;
}

.field-set {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 0.35rem 0.5rem;
  background: var(--surface);
  border: 2px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  min-height: 52px;
}

.field-set.drag-over {
  background: rgba(79, 195, 247, 0.12);
  border-color: var(--accent-primary);
  transition: none !important;
}

/* 不成立セットのスタイル */
.field-set.invalid {
  border-color: rgba(239, 83, 80, 0.6);
  background: rgba(239, 83, 80, 0.08);
}

.field-set.invalid .field-set-label {
  color: var(--tile-red);
}

.field-set-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-right: 3px;
  letter-spacing: 0.05em;
  flex-shrink: 0;
  line-height: 1;
  opacity: 0.8;
}

.field-set-type {
  font-size: 0.6rem;
  color: var(--text-muted);
  margin-left: 5px;
  flex-shrink: 0;
  opacity: 0.6;
}

.field-set.invalid .field-set-type {
  color: var(--tile-red);
  opacity: 1;
}

/* Tile drawn highlight - border-color only (no box-shadow for GPU safety) */
.tile.just-drawn {
  border-color: rgba(253, 216, 53, 0.7) !important;
  outline: 2px solid rgba(253, 216, 53, 0.5);
  outline-offset: 1px;
}

/* Dynamic tile sizes based on field density */
.play-container.compact-tiles .tile,
.drag-ghost.compact-tiles .tile {
  width: 30px;
  height: 40px;
  font-size: 0.85rem;
  border-radius: 4px;
}

.play-container.compact-tiles .field-set {
  gap: 2px;
  padding: 0.25rem 0.4rem;
  min-height: 44px;
}

.play-container.compact-tiles .hand-area {
  min-height: 50px;
  gap: 3px;
}

.play-container.tiny-tiles .tile,
.drag-ghost.tiny-tiles .tile {
  width: 26px;
  height: 34px;
  font-size: 0.75rem;
  border-radius: 3px;
}

.play-container.tiny-tiles .field-set {
  gap: 1px;
  padding: 0.2rem 0.3rem;
  min-height: 38px;
}

.play-container.tiny-tiles .hand-area {
  min-height: 42px;
  gap: 2px;
}

/* ============================
   Action Bar
   ============================ */
.action-bar {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.5rem 1rem;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.action-bar-primary {
  display: flex;
  justify-content: center;
  gap: 0.6rem;
}

.action-bar-secondary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.action-btn {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.4rem 0.65rem;
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform var(--transition-fast), background-color var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast), color var(--transition-fast), opacity var(--transition-fast);
  white-space: nowrap;
  box-shadow: 0 2px 4px rgba(27, 94, 32, 0.1);
}

.action-btn:hover:not(:disabled) {
  background: var(--surface-light);
  color: var(--text-primary);
  transform: translateY(-1px);
}

.action-btn:active:not(:disabled) {
  transform: translateY(0);
}

.action-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Primary draw buttons - larger and more prominent */
.primary-draw {
  padding: 0.55rem 1.5rem;
  font-size: 0.9rem;
  font-weight: 800;
  background: var(--accent-primary);
  border: 2px solid var(--accent-primary);
  border-radius: var(--radius-sm);
  color: #fffef9;
  letter-spacing: 0.05em;
  box-shadow: none;
}

.primary-draw:hover:not(:disabled) {
  background: var(--accent-primary-hover);
  border-color: var(--accent-primary-hover);
  transform: translateY(-1px);
  color: #fffef9;
}

.primary-draw .action-icon {
  font-size: 1.1rem;
}

/* Tile size controls */
.tile-size-controls {
  display: flex;
  gap: 0.2rem;
}

.size-btn {
  padding: 0.35rem 0.5rem;
  font-size: 0.7rem;
}

.action-icon {
  font-size: 0.9rem;
}

.action-text {
  line-height: 1;
}

/* Specific action button styles */
.draw-btn:hover:not(:disabled) {
  border-color: rgba(76, 175, 80, 0.4);
  color: #66bb6a;
}

.reset-btn:hover:not(:disabled) {
  border-color: rgba(255, 167, 38, 0.4);
  color: var(--accent-secondary);
}

.undo-btn:hover:not(:disabled) {
  border-color: rgba(144, 164, 174, 0.4);
}

.ai-btn:hover:not(:disabled) {
  border-color: rgba(79, 195, 247, 0.4);
  color: var(--accent-primary);
}

.ai-answer-btn:hover:not(:disabled) {
  border-color: rgba(255, 235, 59, 0.4);
  color: #fdd835;
}

.save-btn:hover:not(:disabled) {
  border-color: rgba(171, 71, 188, 0.4);
  color: #ba68c8;
}

/* Disabled buttons */
.action-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  filter: grayscale(0.5);
}

.sort-field-btn:hover:not(:disabled) {
  border-color: rgba(79, 195, 247, 0.4);
  color: var(--accent-primary);
}

/* ============================

   Hand Section
   ============================ */
.hand-section {
  flex-shrink: 0;
  background: linear-gradient(180deg, #24567f, #1f4e79);
  border-top: 1px solid var(--border-subtle);
  /* box-shadow Removed: 巨大なエリアへの常駐影はGPU VRAM・TDRクラッシュの原因になるため削除 */
  padding: 0.8rem 1rem 1.2rem;
  width: 100%;
}

.hand-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.hand-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.03em;
}

.hand-label span {
  color: #fffef9;
  font-weight: 800;
}

.sort-buttons {
  display: flex;
  gap: 0.4rem;
}

.sort-btn {
  padding: 0.36rem 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
  box-shadow: 0 1px 3px rgba(27, 94, 32, 0.1);
}

.sort-btn:hover {
  background: var(--surface-light);
  color: var(--text-primary);
  border-color: rgba(46, 125, 50, 0.3);
}

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

.hand-area {
  display: flex;
  align-items: flex-end;
  gap: 5px;
  min-height: 66px;
  padding: 0.4rem 0.6rem;
  background: transparent;
  border-top: none;
  border-bottom: none;
  /* box-shadow Removed: GPU TDR・白飛びクラッシュの最大要因である巨大なぼかし影を完全廃止 */
  border-radius: 4px;
  overflow-x: auto;
}

.hand-area.drag-over {
  background: rgba(79, 195, 247, 0.06);
  border-color: var(--accent-primary);
  /* GPU TDR Fixed: drag-over時のアニメーション補完（再描画の連鎖）を防止 */
  transition: none !important;
}

.hand-area::-webkit-scrollbar {
  height: 4px;
}

.hand-area::-webkit-scrollbar-track {
  background: transparent;
}

.hand-area::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: 2px;
}

/* ============================
   AI Answer Banner
   ============================ */
.ai-answer-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 0.5rem 1rem;
  background: linear-gradient(135deg, rgba(253, 216, 53, 0.15), rgba(255, 167, 38, 0.1));
  border-bottom: 2px solid rgba(253, 216, 53, 0.4);
  flex-shrink: 0;
}

.ai-banner-text {
  font-size: 0.9rem;
  font-weight: 700;
  color: #fdd835;
}

.ai-revert-btn {
  padding: 0.3rem 0.8rem;
  font-size: 0.78rem;
}

/* AI highlight on tiles */
/* AI highlight on tiles - static outline only (no box-shadow animation for GPU safety) */
.tile.ai-moved {
  border-color: rgba(253, 216, 53, 0.8) !important;
  outline: 2.5px solid rgba(253, 216, 53, 0.6);
  outline-offset: 1px;
  position: relative;
}

/* ============================
   Boards List Modal
   ============================ */
.boards-dialog {
  max-width: 440px;
  width: 90%;
}

.boards-list {
  max-height: 300px;
  overflow-y: scroll;
  margin: 0.8rem 0;
}

.board-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.8rem;
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  margin-bottom: 0.4rem;
  transition: background-color var(--transition-fast), border-color var(--transition-fast);
}

.board-item:hover {
  border-color: var(--accent-primary);
  background: var(--surface-light);
}

.board-item-info {
  flex: 1;
}

.board-item-name {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.85rem;
}

.board-item-date {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.board-item-actions {
  display: flex;
  gap: 0.3rem;
}

.board-load-btn,
.board-delete-btn {
  padding: 0.25rem 0.5rem;
  font-size: 0.7rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  font-family: inherit;
  transition: border-color var(--transition-fast), color var(--transition-fast);
}

.board-load-btn:hover {
  border-color: #66bb6a;
  color: #81c784;
}

.board-delete-btn:hover {
  border-color: #ef5350;
  color: #ef5350;
}

.boards-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem 0;
  font-size: 0.85rem;
}

/* ============================
   Notify Modal
   ============================ */
.notify-dialog {
  text-align: center;
  max-width: 340px;
}

.notify-icon {
  font-size: 2.5rem;
  margin-bottom: 0.8rem;
}

.notify-message {
  font-size: 0.95rem;
  color: var(--text-primary);
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

.notify-close-btn {
  min-width: 120px;
}

.notify-dialog.error .notify-icon {
  color: var(--tile-red);
}

.notify-dialog.success .notify-icon {
  color: #66bb6a;
}

/* ============================
   Clear Modal
   ============================ */
.clear-dialog {
  text-align: center;
  max-width: 380px;
  position: relative;
}

.clear-stars {
  font-size: 3rem;
  margin-bottom: 0.5rem;
  animation: clearBounce 0.6s ease-out;
}

.clear-title {
  font-size: 2rem;
  font-weight: 900;
  color: #fdd835;
  margin-bottom: 0.6rem;
  letter-spacing: 0.1em;
  text-shadow: 0 2px 10px rgba(253, 216, 53, 0.3);
}

.clear-message {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
  line-height: 1.7;
}

.clear-actions {
  display: flex;
  gap: 0.8rem;
}

@keyframes clearBounce {
  0% {
    transform: scale(0.3);
    opacity: 0;
  }

  50% {
    transform: scale(1.15);
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ============================
   Animations
   ============================ */
@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes modalSlideUp {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.95);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes tileFloat {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-6px);
  }
}

@keyframes shimmer {

  0%,
  100% {
    transform: translateX(-100%);
  }

  50% {
    transform: translateX(100%);
  }
}

.step-image {
  width: 100%;
  aspect-ratio: 16 / 9; /* Mantain aspect ratio of screenshots */
  height: auto;
  max-height: 400px;
  background: #e8f5e9;
  border: 2px dashed #81c784;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.5rem;
  color: var(--text-secondary);
  font-weight: bold;
  font-size: 1.2rem;
  text-shadow: 0 1px 2px rgba(255,255,255,0.8);
  box-sizing: border-box;
  overflow: hidden;
}

.step-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: calc(var(--radius-md) - 2px);
}

.step-desc {
  font-size: 1rem;
  color: var(--text-primary);
  line-height: 1.6;
  margin-bottom: 1.5rem;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-text {
  font-size: 1.2rem;
  font-weight: 600;
  text-align: center;
  line-height: 1.5;
  color: #ffffff;
  /* Must be explicitly white due to dark overlay */
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* ============================
   Responsive Design
   ============================ */
@media (max-width: 480px) {
  .top-container {
    padding: 1.5rem 1rem;
  }

  .logo-tile {
    width: 38px;
    height: 48px;
    font-size: 1.2rem;
  }

  .app-title {
    font-size: 1.7rem;
  }

  .title-accent {
    font-size: 1.1rem;
  }

  .mode-btn {
    padding: 1rem 1.2rem;
    gap: 1rem;
  }

  .mode-btn-icon {
    width: 44px;
    height: 44px;
    font-size: 1.6rem;
  }

  .mode-btn-title {
    font-size: 1rem;
  }

  .modal-dialog {
    padding: 1.5rem;
  }

  /* Play screen mobile */
  .tile {
    width: 36px;
    height: 48px;
    font-size: 1rem;
    border-radius: 5px;
  }

  .action-bar {
    gap: 0.3rem;
    padding: 0.5rem 0.5rem;
  }

  .action-btn {
    padding: 0.35rem 0.5rem;
    font-size: 0.7rem;
  }

  .action-text {
    display: none;
  }

  .action-icon {
    font-size: 1.1rem;
  }

  .field-area {
    padding: 0.6rem;
  }

  .hand-section {
    padding: 0.4rem 0.5rem 0.6rem;
  }

  .field-set {
    padding: 0.4rem;
    gap: 3px;
    min-height: 58px;
  }
}

@media (min-width: 768px) {
  .mode-selection {
    flex-direction: row;
    max-width: 680px;
  }

  .mode-btn {
    flex: 1;
    flex-direction: column;
    text-align: center;
    padding: 1.8rem 1.5rem;
  }

  .mode-btn::before {
    width: 100%;
    height: 4px;
    border-radius: 4px 4px 0 0;
  }

  .mode-btn:hover {
    transform: translateY(-4px);
  }

  .mode-btn:hover::before {
    width: 100%;
    height: 6px;
  }

  .mode-btn:active {
    transform: translateY(-2px) scale(0.99);
  }

  .mode-btn-icon {
    width: 64px;
    height: 64px;
    font-size: 2.2rem;
  }

  .mode-btn-text {
    align-items: center;
  }

  .app-title {
    font-size: 2.6rem;
  }

  .title-accent {
    font-size: 1.6rem;
  }

  /* Play screen tablet+ */
  .tile {
    width: 46px;
    height: 60px;
    font-size: 1.25rem;
  }

  .field-area {
    padding: 1.2rem 1.5rem;
  }

  .hand-area {
    gap: 6px;
  }
}

@media (min-width: 1024px) {
  .logo-tile {
    width: 56px;
    height: 70px;
    font-size: 1.8rem;
  }

  .logo-tiles {
    gap: 8px;
  }

  .tile {
    width: 48px;
    height: 64px;
    font-size: 1.3rem;
  }

  .field-set {
    gap: 5px;
    padding: 0.6rem 0.8rem;
  }
}

/* ============================
   Build Mode - Layout
   ============================ */
.build-badge {
  background: rgba(255, 255, 255, 0.8);
  color: #2e7d32;
  border: 1px solid rgba(76, 175, 80, 0.4);
}

.build-container {
  display: grid !important;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto 1fr;
  height: calc(var(--vh, 1vh) * 100);
}

.build-container>.play-header {
  grid-column: 1 / -1;
}

.build-container>.tile-palette {
  grid-column: 1;
  grid-row: 2;
}

.build-container>.build-right-area {
  grid-column: 2;
  grid-row: 2;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

/* ============================
   Build Mode - Tile Palette
   ============================ */
.tile-palette {
  padding: 0.5rem 0.6rem;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-subtle);
  flex-shrink: 0;
  overflow-y: scroll;
  overflow-x: hidden;
  max-height: calc((var(--vh, 1vh) * 100) - 50px);
}

.palette-label {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.08em;
  margin-bottom: 0.3rem;
  text-transform: uppercase;
}

.palette-grid {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.palette-color-group {
  display: flex;
  flex-direction: column;
  gap: 0px;
}

.palette-color-label {
  font-size: 0.55rem;
  font-weight: 800;
  color: var(--text-secondary);
  padding: 0 2px;
  margin-bottom: 0px;
  margin-top: 2px;
  letter-spacing: 0.05em;
}

.palette-row {
  display: flex;
  gap: 1px;
  flex-wrap: nowrap;
}

.palette-tile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 32px;
  border-radius: 3px;
  font-size: 0.7rem;
  font-weight: 800;
  color: #333;
  cursor: grab;
  user-select: none;
  position: relative;
  background-color: #e8d5b5;
  border: 1px solid #c9bda8;
  flex-shrink: 0;
}

.palette-tile:hover:not(.used) {
  transform: translateY(-1px);
  z-index: 2;
}

.palette-tile:active:not(.used) {
  transform: translateY(0);
}

.palette-tile.used {
  opacity: 0.2;
  pointer-events: none;
  filter: grayscale(0.6);
}

.palette-tile.selected {
  outline: 2px solid #fdd835;
  outline-offset: -1px;
  z-index: 3;
}

.palette-tile.tile-red {
  color: #d32f2f;
}

.palette-tile.tile-blue {
  color: #1976d2;
}

.palette-tile.tile-black {
  color: #212121;
}

.palette-tile.tile-orange {
  color: #f57c00;
}

.palette-tile.tile-joker {
  color: #7b1fa2;
  font-size: 0.9rem;
}

/* ============================
   Build Mode - Action Bar
   ============================ */
.build-action-bar {
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.build-actions-left {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.build-load-btn:hover:not(:disabled) {
  border-color: rgba(76, 175, 80, 0.4);
  color: #66bb6a;
}

.redo-btn:hover:not(:disabled) {
  border-color: rgba(144, 164, 174, 0.4);
}

/* ============================
   Build Mode - Trash Button (Circle)
   ============================ */
.build-trash-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  background: linear-gradient(145deg, rgba(239, 83, 80, 0.15), rgba(198, 40, 40, 0.1));
  border: 2px solid rgba(239, 83, 80, 0.3);
  color: #ef5350;
  cursor: default;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
  position: relative;
}

.build-trash-btn.drag-over,


@keyframes trashPulse {

  0%,
  100% {
    box-shadow: 0 0 10px rgba(239, 83, 80, 0.3);
  }

  50% {
    box-shadow: 0 0 20px rgba(239, 83, 80, 0.6);
  }
}

/* ============================
   Build Mode - Same-Set Timer Indicator
   ============================ */
/* Build mode accepting-tile indicator - static style only (no box-shadow animation for GPU safety) */
.field-set.accepting-tile {
  border-color: rgba(102, 187, 106, 0.9) !important;
  outline: 2px solid rgba(102, 187, 106, 0.4);
  outline-offset: 1px;
}

.field-set-label .accept-icon {
  margin-left: 3px;
  font-size: 0.6rem;
}

/* ============================
   Build Mode - Responsive
   ============================ */
@media (max-width: 600px) {
  .build-container {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr;
  }

  .build-container>.tile-palette {
    grid-column: 1;
    grid-row: 2;
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
    max-height: 35vh;
    overflow-y: auto;
  }

  .build-container>.build-right-area {
    grid-column: 1;
    grid-row: 3;
  }

  .palette-tile {
    width: 22px;
    height: 26px;
    font-size: 0.55rem;
    border-radius: 2px;
  }

  .palette-tile.tile-joker {
    font-size: 0.7rem;
  }

  .tile-palette {
    padding: 0.3rem 0.4rem;
  }

  .build-trash-btn {
    width: 44px;
    height: 44px;
    font-size: 1.1rem;
  }
}

@media (min-width: 768px) {
  .palette-tile {
    width: 32px;
    height: 38px;
    font-size: 0.8rem;
  }

  .palette-tile.tile-joker {
    font-size: 1rem;
  }
}

/* ============================
   認証・ユーザー設定
   ============================ */

.user-status-area {
  margin-bottom: 1rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.text-link-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  text-decoration: underline;
  cursor: pointer;
  padding: 0.2rem 0.5rem;
  font-size: inherit;
  transition: color 0.2s;
}

.text-link-btn:hover {
  color: var(--accent-primary);
}

.user-name-display {
  margin-right: 0.5rem;
  font-weight: 500;
  color: var(--text-primary);
}

.auth-input {
  width: 100%;
  padding: 0.8rem;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 1rem;
}

.auth-input:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

.auth-error {
  color: #ff5252;
  font-size: 0.8rem;
  margin-top: 0.5rem;
}

.profile-info {
  text-align: left;
}

.profile-row {
  display: flex;
  flex-direction: column;
}

.profile-row-simple {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 1rem;
}

.profile-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: bold;
}

.profile-value {
  font-size: 0.95rem;
  color: var(--text-primary);
  word-break: break-all;
}

/* Settings Sections */
.settings-section {
  margin-top: 0.8rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-card);
}

.section-toggle-btn {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.8rem 1rem;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s;
}

.section-toggle-btn:hover {
  background: var(--surface-light);
}

.section-toggle-btn .toggle-icon {
  font-size: 0.7rem;
  transition: transform 0.3s;
}

.settings-section.active .toggle-icon {
  transform: rotate(180deg);
}

.section-content {
  padding: 1rem;
  background: var(--surface);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.section-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.btn-sm-save {
  padding: 0.6rem 1rem !important;
  font-size: 0.85rem !important;
  align-self: flex-end;
}

.modal-overlay.active.mandatory {
  backdrop-filter: blur(8px);
  background: rgba(0, 0, 0, 0.9);
}

/* ============================
   Clear Modal Result Area
   ============================ */
#clear-score-area {
  margin: 1.5rem 0;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  opacity: 0;
  transform: translateY(10px) scale(0.95);
  transition: opacity 0.6s cubic-bezier(0.2, 0.8, 0.2, 1), transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}

#clear-score-area.show-result {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.result-rank {
  font-size: 3.5rem;
  font-weight: 900;
  line-height: 1;
  margin-bottom: 0.5rem;
  letter-spacing: -0.05em;
  text-shadow: 0 4px 15px rgba(255, 255, 255, 0.2);
}

.rank-s { color: #fdd835; text-shadow: 0 0 20px rgba(253, 216, 53, 0.6), 0 0 40px rgba(253, 216, 53, 0.3); animation: rankPulse 2s infinite alternate; }
.rank-a { color: #ff8a65; text-shadow: 0 0 15px rgba(255, 138, 101, 0.5); }
.rank-b { color: #4fc3f7; text-shadow: 0 0 15px rgba(79, 195, 247, 0.5); }
.rank-c { color: #81c784; }
.rank-d { color: #a1887f; }
.rank-e { color: #9e9e9e; }

@keyframes rankPulse {
  from { transform: scale(1); }
  to { transform: scale(1.05); }
}

.result-score {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.score-label {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-secondary);
  letter-spacing: 0.1em;
}

.score-value {
  font-size: 2.2rem;
  font-weight: 900;
  color: var(--text-primary);
}

.result-detail {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}
/* ============================
   詰めラミィモード
   ============================ */
.tsume-level-list {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.tsume-level-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
  width: 100%;
  padding: 0.95rem 1.2rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  text-align: left;
  transition: transform var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.tsume-level-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-md);
}

.tsume-level-btn:disabled {
  opacity: 0.5;
  cursor: wait;
}

.tsume-level-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
}

.tsume-level-btn[data-level="easy"] .tsume-level-name { color: #2e7d32; }
.tsume-level-btn[data-level="normal"] .tsume-level-name { color: #ef6c00; }
.tsume-level-btn[data-level="hard"] .tsume-level-name { color: #c62828; }

.tsume-level-desc {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

/* ============================
   スコアパッドテーマ 造形上書き (案B + B-3濃紺バンド)
   紙とインクの様式: インク輪郭のタイル・罫線の場・スタンプボタン・濃紺バンドの手札
   ============================ */

/* --- タイル: フラット+インク輪郭+オフセット影(紙片) --- */
.tile {
  background-color: #fffef9;
  border: 1.5px solid var(--ink-line);
  border-radius: 3px;
  box-shadow: 2px 2px 0 rgba(42, 49, 64, 0.18);
}

.tile.selected {
  outline: 2.5px solid var(--tile-red);
  outline-offset: 1px;
}

/* --- ロゴタイルも同じ紙片様式に --- */
.logo-tile {
  background: #fffef9;
  border: 1.5px solid var(--ink-line);
  box-shadow: 3px 3px 0 rgba(42, 49, 64, 0.18);
}

.logo-tile::after {
  display: none;
}

/* --- 場: 罫線ノート+セットは濃紺アンダーライン --- */
.field-area {
  background:
    repeating-linear-gradient(180deg, transparent 0 34px, rgba(31, 78, 121, 0.08) 34px 35px);
}

.field-set {
  background: transparent;
  border: none;
  border-bottom: 2.5px solid var(--accent-primary);
  border-radius: 0;
  padding: 0.3rem 0.45rem 0.45rem;
}

.field-set.drag-over {
  background: rgba(31, 78, 121, 0.08);
  border-bottom-color: var(--accent-primary);
}

.field-set.invalid {
  background: rgba(214, 67, 57, 0.07);
  border-bottom-color: var(--tile-red);
}

/* --- ヘッダー/アクションバー: 紙+インクの太罫 --- */
.play-header {
  border-bottom: 2px solid var(--ink);
}

.action-bar {
  border-top: 2px solid var(--ink);
  border-bottom: none;
}

/* --- ボタン: スタンプ(枠線)様式 --- */
.action-btn {
  background: transparent;
  border: 2px solid var(--accent-primary);
  border-radius: 3px;
  color: var(--accent-primary);
  font-weight: 800;
  letter-spacing: 0.03em;
  box-shadow: none;
}

.action-btn:hover:not(:disabled) {
  background: rgba(31, 78, 121, 0.08);
  color: var(--accent-primary);
}

.primary-draw {
  background: var(--accent-primary);
  border: 2px solid var(--accent-primary);
  border-radius: 3px;
  color: #fffef9;
}

.primary-draw:hover:not(:disabled) {
  background: var(--accent-primary-hover);
  border-color: var(--accent-primary-hover);
  color: #fffef9;
}

.btn-back {
  background: transparent;
  border: 1.5px solid #7a8290;
  border-radius: 3px;
  color: var(--text-secondary);
  font-weight: 700;
}

.btn-back:hover {
  background: rgba(31, 78, 121, 0.06);
  color: var(--text-primary);
}

.badge {
  border-radius: 3px;
}

.btn-secondary {
  background: transparent;
  color: var(--text-secondary);
  border: 2px solid #7a8290;
  border-radius: 3px;
  font-weight: 800;
}

.btn-secondary:hover {
  background: rgba(31, 78, 121, 0.06);
}

/* --- 手札: B-3 濃紺バンド --- */
.hand-label {
  color: #fffef9;
  letter-spacing: 0.15em;
}

.sort-btn {
  background: transparent;
  border: 1.5px solid rgba(255, 254, 249, 0.55);
  border-radius: 3px;
  color: #cfdcea;
  box-shadow: none;
}

.sort-btn:hover {
  background: rgba(255, 254, 249, 0.12);
  border-color: rgba(255, 254, 249, 0.8);
  color: #fffef9;
}

.hand-area .tile {
  border-color: #16385a;
  box-shadow: 2px 2px 0 rgba(10, 26, 42, 0.5);
}

.hand-area.drag-over {
  background: rgba(255, 254, 249, 0.1);
  border: none;
}

.hand-area::-webkit-scrollbar-thumb {
  background: rgba(255, 254, 249, 0.4);
}

/* --- 選択矩形・ドラッグゴースト --- */
.selection-rect {
  border: 2px dashed rgba(31, 78, 121, 0.7);
  background: rgba(31, 78, 121, 0.08);
}

.drag-ghost {
  background: rgba(255, 254, 249, 0.65);
}

/* --- 言語ボタン --- */
.lang-btn {
  background: transparent;
  border: 1.5px solid #7a8290;
  border-radius: 3px;
  color: var(--text-secondary);
  backdrop-filter: none;
}

.lang-btn:hover {
  background: rgba(31, 78, 121, 0.06);
  border-color: var(--accent-primary);
  color: var(--text-primary);
}

.lang-btn.active {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #fffef9;
}

/* --- 詰めラミィ: 難易度ボタンと解答表示も紙とインクに --- */
.tsume-level-btn {
  border: 2px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

.tsume-level-btn:hover:not(:disabled) {
  border-color: var(--accent-primary);
  box-shadow: none;
  transform: none;
  background: rgba(31, 78, 121, 0.05);
}

/* --- AI解答バナー (スコアパッド様式) --- */
.ai-answer-banner {
  background: rgba(214, 67, 57, 0.07);
  border-bottom: 2px solid var(--accent-secondary);
}

.ai-banner-text {
  color: var(--accent-secondary);
}

.ai-revert-btn {
  border-color: var(--accent-secondary);
  color: var(--accent-secondary);
}

.ai-revert-btn:hover:not(:disabled) {
  background: rgba(180, 84, 46, 0.08);
  color: var(--accent-secondary);
}

/* ============================
   PC/スマホ 出し分け
   ・.pc-only-mode  … 詰めラミィ・盤面作成・保存した問題 → PCのみ表示
   ・.mobile-only-mode … スマートフォンモード → スマホのみ表示
   ============================ */
.pc-only-tag {
  position: absolute;
  top: 10px;
  right: 12px;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--accent-primary);
  border: 1.5px solid var(--accent-primary);
  border-radius: 3px;
  padding: 1px 6px;
  background: rgba(31, 78, 121, 0.06);
}

/* スマホ専用モードはPCでは隠す(既定) */
.mobile-only-mode {
  display: none;
}

/* スマホ: PC専用モードを隠し、スマホ専用モードを表示。
   縦持ち(狭幅)に加え、横持ちスマホ(タッチ操作+950px以下)も捕捉する。 */
@media (max-width: 700px), (pointer: coarse) and (max-width: 950px) {
  .pc-only-mode {
    display: none !important;
  }
  .mobile-only-mode {
    display: flex;
  }
}

/* --- 盤面作成モード: パレットタイルもスコアパッド様式に --- */
.palette-tile {
  background-color: #fffef9;
  border: 1.5px solid var(--ink-line);
  border-radius: 3px;
  box-shadow: 1px 1px 0 rgba(42, 49, 64, 0.18);
}

.palette-tile.selected {
  outline: 2.5px solid var(--tile-red);
  outline-offset: 1px;
}

/* --- 旧アクセント色の残り(緑/水色/黄)をスコアパッドへ統一 --- */
.tsume-btn::before { background: #c99a2e; }                   /* 詰めラミィの左レール(金茶ゴールド) */
.build-btn::before { background: var(--accent-secondary); }   /* 作成モードの左レール(緑→朱) */
.build-badge { color: var(--accent-primary); }                /* 作成モードのバッジ(緑→濃紺) */
.clear-title { color: var(--accent-secondary); }              /* クリア見出し(黄→朱) */
/* クリア画面ランク色(水色/緑の旧アクセントを廃止) */
.rank-s { color: #c99a2e; text-shadow: none; animation: none; }
.rank-a { color: var(--accent-secondary); text-shadow: none; }
.rank-b { color: var(--accent-primary); text-shadow: none; }
.rank-c { color: var(--text-secondary); text-shadow: none; }
/* 保存済み一覧ボタンのhover(緑/赤の旧色→テーマ) */
.board-load-btn:hover { border-color: var(--accent-primary); color: var(--accent-primary); }
.board-delete-btn:hover { border-color: var(--tile-red); color: var(--tile-red); }

/* ============================================================
   詰めラミィ 解答画面 (screen-answer)
   ============================================================ */
.answer-container { background: var(--bg-secondary); }

.answer-title {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: 0.03em;
}

.answer-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 1rem 1.2rem 1.4rem;
}

.answer-section { margin-bottom: 1.4rem; }

.answer-section-title {
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--accent-primary);
  border-bottom: 2px solid var(--ink);
  padding-bottom: 4px;
  margin-bottom: 0.8rem;
}

.answer-board {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 18px;
}

.answer-set {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 4px 6px 6px;
  border-bottom: 2.5px solid var(--accent-primary);
}
.answer-set.answer-dim { opacity: 0.4; }

.answer-board .tile,
.answer-hand .tile {
  width: 30px;
  height: 40px;
  font-size: 1rem;
  pointer-events: none;
  cursor: default;
  flex-shrink: 0;
}

/* 手札から出すタイルのグロー(詰めラミィのテーマ色=金茶) */
.answer-glow {
  outline: 2.5px solid #c99a2e;
  outline-offset: 1px;
  box-shadow: 0 0 9px 1px rgba(201, 154, 46, 0.75) !important;
  z-index: 2;
  animation: answerGlowPulse 1.6s ease-in-out infinite;
}
@keyframes answerGlowPulse {
  0%, 100% { box-shadow: 0 0 6px 1px rgba(201, 154, 46, 0.55) !important; }
  50%      { box-shadow: 0 0 12px 2px rgba(201, 154, 46, 0.9) !important; }
}
@media (prefers-reduced-motion: reduce) {
  .answer-glow { animation: none; }
}

/* 問題の手札は濃紺バンドで表示 */
.answer-hand-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 0.8rem;
  background: linear-gradient(180deg, #24567f, #1f4e79);
  border-radius: 6px;
  padding: 8px 12px;
}
.answer-hand-label {
  color: #fffef9;
  font-weight: 800;
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  flex-shrink: 0;
}
.answer-hand { display: flex; flex-wrap: wrap; gap: 4px; }
.answer-hand .tile { border-color: #16385a; }

.answer-legend {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-top: 0.4rem;
}

.answer-actions { justify-content: center; gap: 0.6rem; }

/* クリア画面を閉じて盤面を見るボタン */
.clear-close-btn {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1.5px solid #7a8290;
  border-radius: 3px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 800;
  cursor: pointer;
  line-height: 1;
  transition: background-color var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}
.clear-close-btn:hover {
  background: rgba(31, 78, 121, 0.08);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

/* Googleログインボタン */
.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0.85rem 1rem;
  background: #ffffff;
  border: 1.5px solid var(--ink-line);
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  cursor: pointer;
  box-shadow: 2px 2px 0 rgba(42, 49, 64, 0.12);
  transition: background-color var(--transition-fast), transform var(--transition-fast);
}
.btn-google:hover {
  background: var(--surface-light);
  transform: translateY(-1px);
}
.btn-google:active { transform: translateY(0); }
.btn-google svg { flex-shrink: 0; }
