* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --c-bg: #1a1a2e;
  --c-panel-1: #16213e;
  --c-panel-2: #0f3460;
  --c-text: #e0e0e0;
  --c-muted: #a0a0c0;
  --c-accent: #e94560;
  --c-hint: #fff01a;
  --rgb-hint: 255, 240, 26;
  --c-info: #3498db;
  --c-warn: #f39c12;
  --c-warn-hover: #e67e22;
  --c-success: #2ecc71;
  --c-neutral: #555;
  --c-white: #fff;
  --c-cell: #0f3460; /*#965A1B*/
  --rgb-accent: 233, 69, 96;
  --rgb-black: 0, 0, 0;
  --rgb-white: 255, 255, 255;
  --rgb-panel-2: 15, 52, 96;
}

body { min-height: 100vh; display: flex; justify-content: center; align-items: center; background: var(--c-bg); font-family: 'Segoe UI', sans-serif; overflow-x: hidden; }
@media (max-height: 700px), (max-width: 480px) {
  body { align-items: flex-start; padding: 8px 0; overflow-y: auto; }
}
#game-container { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 8px; width: 100%; max-width: 600px; }
#header { background: linear-gradient(135deg, var(--c-panel-1), var(--c-panel-2)); border-radius: 12px; padding: 10px 32px; text-align: center; color: var(--c-text); width: 100%; position: relative; }
#header h1 { font-size: 20px; color: var(--c-accent); margin-bottom: 2px; }
#header .info { font-size: 13px; color: var(--c-muted); }
#hint-btn { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); background: none; border: 2px solid var(--c-hint); border-radius: 50%; width: 34px; height: 34px; font-size: 18px; cursor: pointer; color: var(--c-hint); transition: all .2s; }
#hint-btn:hover { background: var(--c-hint); color: var(--c-bg); }
.header-btn { position: absolute; top: 50%; transform: translateY(-50%); background: none; border-radius: 50%; width: 34px; height: 34px; font-size: 18px; cursor: pointer; transition: all .2s; }
#icon-lib-btn { left: 8px; border: 2px solid var(--c-info); color: var(--c-info); }
#recognize-btn { left: 46px; border: 2px solid var(--c-warn); color: var(--c-warn); }
#ai-solve-btn { right: 46px; border: 2px solid var(--c-success); color: var(--c-success); }
#board-wrapper { position: relative; }
#board { display: grid; gap: 2px; background: var(--c-panel-1); border-radius: 8px; padding: 4px; box-shadow: 0 0 30px rgba(var(--rgb-accent), .15); }
.cell { background: var(--c-cell); border-radius: 3px; }
.brick { border-radius: 5px; display: flex; align-items: center; justify-content: center; font-size: 18px; cursor: grab; user-select: none; position: absolute; z-index: 2; transition: none; pointer-events: auto; }
.brick .brick-id {
  position: absolute;
  left: 50%;
  top: -6px;
  transform: translateX(-50%);
  font-size: 11px;
  line-height: 11px;
  padding: 0 5px;
  border-radius: 7px;
  background: rgba(var(--rgb-black), .55);
  color: var(--c-white);
  z-index: 4;
  pointer-events: none;
  text-shadow: 0 1px 1px rgba(var(--rgb-black), .6);
  white-space: nowrap;
}
.brick:hover { filter: brightness(1.2); }
.brick.selected { box-shadow: 0 0 10px 3px rgba(var(--rgb-white), .6); z-index: 3; }
.brick.candidate { animation: candidatePulse .8s ease-in-out infinite; z-index: 3; }
@keyframes candidatePulse { 0%,100% { box-shadow: 0 0 6px 2px var(--c-success); filter: brightness(1.3); } 50% { box-shadow: 0 0 16px 5px var(--c-success); filter: brightness(1.6); } }
.brick.hint { animation: hintPulse .55s ease-in-out infinite; z-index: 3; outline: 2px solid rgba(var(--rgb-hint), .95); outline-offset: 0; }
@keyframes hintPulse {
  0%, 100% { box-shadow: 0 0 4px 2px rgba(var(--rgb-hint), .9), 0 0 14px 4px rgba(var(--rgb-hint), .45); filter: brightness(1.15); }
  50% { box-shadow: 0 0 10px 4px rgba(var(--rgb-hint), 1), 0 0 28px 10px rgba(var(--rgb-hint), .65); filter: brightness(1.35); }
}
.hint-slide-path-arrow {
  position: absolute;
  transform: translate(-50%, -50%);
  z-index: 7;
  font-size: clamp(34px, 7vw, 56px);
  line-height: 1;
  font-weight: 900;
  color: rgba(110, 236, 255, .98);
  text-shadow: 0 0 8px rgba(110, 236, 255, .85), 0 0 18px rgba(110, 236, 255, .55), 0 1px 2px rgba(var(--rgb-black), .65);
  animation: hintArrowBlink .55s ease-in-out infinite;
  pointer-events: none;
  user-select: none;
}
@keyframes hintArrowBlink {
  0%, 100% { opacity: .55; transform: translate(-50%, -50%) scale(0.94); filter: brightness(1); }
  50% { opacity: 1; transform: translate(-50%, -50%) scale(1.08); filter: brightness(1.35); }
}
.brick.sliding { transition: left .2s ease-out, top .2s ease-out; }
.brick.type-shake { animation: typeShake .3s ease-in-out 3; }
@keyframes typeShake {
  0%, 100% { transform: translateY(0); }
  25% { transform: translateY(-1.5px); }
  50% { transform: translateY(0.8px); }
  75% { transform: translateY(-1px); }
}
.brick.removing { animation: pop .3s ease-out forwards; pointer-events: none; }
@keyframes pop { to { transform: scale(0) rotate(30deg); opacity: 0; } }
.connect-line { position: absolute; background: rgba(var(--rgb-accent), .5); z-index: 1; border-radius: 3px; animation: lineFade .3s ease-out forwards; }
@keyframes lineFade { 0% { opacity: 1; } 100% { opacity: 0; } }
#message { position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%); background: rgba(var(--rgb-panel-2), .95); color: var(--c-accent); font-size: 26px; padding: 28px 44px; border-radius: 16px; border: 2px solid var(--c-accent); display: none; z-index: 100; text-align: center; }
#message button { margin-top: 14px; padding: 7px 22px; background: var(--c-accent); color: var(--c-white); border: none; border-radius: 8px; font-size: 15px; cursor: pointer; }
#controls { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; width: 100%; }
#controls button { padding: 5px 12px; background: var(--c-panel-2); color: var(--c-muted); border: 1px solid var(--c-muted); border-radius: 6px; cursor: pointer; font-size: 12px; }
#controls button:hover { background: var(--c-accent); color: var(--c-white); border-color: var(--c-accent); }
#controls button:disabled { opacity: .4; cursor: not-allowed; background: var(--c-panel-2); color: var(--c-muted); border-color: var(--c-muted); }
/* 图标库弹窗 */
#icon-modal { position: fixed; inset: 0; background: rgba(var(--rgb-black), .6); display: none; z-index: 200; justify-content: center; align-items: center; }
#icon-modal.open { display: flex; }
#icon-inner { background: var(--c-panel-1); border-radius: 14px; padding: 24px 20px; color: var(--c-text); text-align: center; width: 90vw; max-width: 480px; max-height: 80vh; overflow-y: auto; }
#icon-inner h3 { color: var(--c-accent); margin-bottom: 8px; }
.icon-desc { font-size: 12px; color: var(--c-muted); margin-bottom: 12px; }
.icon-grid { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.icon-item { width: 44px; height: 44px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 22px; cursor: pointer; border: 2px solid transparent; transition: all .2s; position: relative; }
.icon-item.active { background: var(--c-panel-2); border-color: var(--c-success); }
.icon-item.disabled { background: var(--c-bg); border-color: var(--c-neutral); opacity: .4; }
.icon-item.disabled::after { content: '✕'; position: absolute; font-size: 12px; color: var(--c-accent); bottom: 0; right: 2px; }
/* 米糊解题面板 — 居中弹窗 */
#ai-panel { position: fixed; inset: 0; background: rgba(var(--rgb-black), .6); z-index: 150; display: none; justify-content: center; align-items: center; }
#ai-panel.open { display: flex; }
#ai-panel-inner { background: var(--c-panel-1); border-radius: 14px; border: 2px solid var(--c-accent); padding: 16px 16px; color: var(--c-text); display: flex; flex-direction: column; align-items: center; width: 90vw; max-width: 480px; max-height: 80vh; overflow-y: auto; }
#ai-panel-inner h3 { color: var(--c-accent); margin-bottom: 8px; text-align: center; }
#ai-status { font-size: 13px; color: var(--c-muted); text-align: center; margin-bottom: 10px; min-height: 20px; }
#ai-board-mini { margin: 0 auto 10px; position: relative; }
#ai-board-mini .mini-cell { background: var(--c-panel-2); border-radius: 2px; }
#ai-board-mini .mini-brick { position: absolute; border-radius: 3px; display: flex; align-items: center; justify-content: center; font-size: 10px; }
#ai-steps { overflow-y: auto; font-size: 12px; margin: 8px 0; max-height: 120px; width: 100%; }
#ai-steps .step-item { padding: 3px 8px; border-radius: 4px; margin-bottom: 2px; cursor: pointer; }
#ai-steps .step-item:hover { background: var(--c-panel-2); }
#ai-steps .step-item.current { background: var(--c-accent); color: var(--c-white); }
#ai-controls { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
#ai-controls button { padding: 5px 14px; background: var(--c-panel-2); color: var(--c-muted); border: 1px solid var(--c-muted); border-radius: 6px; cursor: pointer; font-size: 12px; }
#ai-controls button:hover { background: var(--c-accent); color: var(--c-white); border-color: var(--c-accent); }
#ai-controls button:disabled { opacity: .4; cursor: not-allowed; }
#custom-modal { position: fixed; inset: 0; background: rgba(var(--rgb-black), .6); display: none; z-index: 200; justify-content: center; align-items: center; }
#custom-modal.open { display: flex; }
#custom-inner { background: var(--c-panel-1); border-radius: 14px; padding: 24px 20px; color: var(--c-text); text-align: center; width: 90vw; max-width: 360px; }
#custom-inner h3 { color: var(--c-accent); margin-bottom: 8px; }
.custom-desc { font-size: 12px; color: var(--c-muted); margin-bottom: 12px; }
#custom-inner label { font-size: 14px; }
#custom-inner input { width: 60px; padding: 4px; border-radius: 4px; border: 1px solid var(--c-muted); background: var(--c-panel-2); color: var(--c-white); text-align: center; font-size: 14px; }
.custom-preview { margin: 12px 0; font-size: 20px; line-height: 1.6; word-break: break-all; }
.custom-btns { display: flex; gap: 10px; justify-content: center; margin-top: 10px; }
.custom-btns button { padding: 6px 18px; border-radius: 6px; border: none; cursor: pointer; font-size: 13px; background: var(--c-accent); color: var(--c-white); }
.custom-btns .cancel { background: var(--c-neutral); }
/* 图片识别弹窗 */
#recognize-modal { position: fixed; inset: 0; background: rgba(var(--rgb-black), .6); display: none; z-index: 200; justify-content: center; align-items: center; }
#recognize-modal.open { display: flex; }
#recognize-inner { background: var(--c-panel-1); border-radius: 14px; padding: 24px 20px; color: var(--c-text); text-align: center; width: 90vw; max-width: 500px; max-height: 85vh; overflow-y: auto; }
#recognize-inner h3 { color: var(--c-warn); margin-bottom: 8px; }
.recognize-desc { font-size: 14px; color: var(--c-muted); margin-bottom: 12px; }
#recognize-status { font-size: 13px; color: var(--c-muted); margin-bottom: 12px; min-height: 20px; }
.recognize-upload-btn { display: inline-block; padding: 8px 20px; background: var(--c-warn); color: var(--c-white); border-radius: 8px; cursor: pointer; font-size: 14px; transition: all .2s; }
.recognize-upload-btn:hover { background: var(--c-warn-hover); }
#recognize-confirm { display: flex; gap: 10px; justify-content: center; margin-top: 12px; }
#recognize-confirm button { padding: 6px 18px; border-radius: 6px; border: none; cursor: pointer; font-size: 13px; background: var(--c-success); color: var(--c-white); }
#recognize-confirm .cancel { background: var(--c-neutral); }
/* 加载动画 */
.ai-loading { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.ai-spinner { width: 32px; height: 32px; border: 3px solid var(--c-panel-2); border-top-color: var(--c-accent); border-radius: 50%; animation: aiSpin 1s linear infinite; }
@keyframes aiSpin { to { transform: rotate(360deg); } }
.ai-progress-bar { width: 200px; height: 8px; background: var(--c-panel-2); border-radius: 4px; overflow: hidden; }
.ai-progress-fill { height: 100%; background: linear-gradient(90deg, var(--c-accent), var(--c-warn)); border-radius: 4px; width: 0; transition: width .2s; }
.ai-progress-text { font-size: 12px; color: var(--c-muted); }
/* 小屏适配 */
@media (max-width: 480px) {
  #header { padding: 8px 36px; border-radius: 8px; }
  #header h1 { font-size: 16px; }
  #header .info { font-size: 11px; }
  .header-btn, #hint-btn { width: 26px; height: 26px; font-size: 13px; }
  #icon-lib-btn { left: 4px; }
  #recognize-btn { left: 34px; }
  #ai-solve-btn { right: 34px; }
  #hint-btn { right: 4px; }
  #controls button { padding: 4px 8px; font-size: 11px; }
  #message { font-size: 20px; padding: 20px 28px; }
  #board { border-radius: 6px; }
}

