:root {
    --iphone-width: 414px;
    --iphone-height: 896px;
}

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

body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: #f0f0f0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.game-container {
    width: var(--iphone-width);
    height: var(--iphone-height);
    background-color: #ffffff;
    padding: 20px;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.back-button {
    position: absolute;
    top: 20px;
    left: 20px;
    display: flex;
    align-items: center;
    text-decoration: none;
    color: #007AFF;
    font-size: 16px;
    gap: 4px;
}

h1 {
    text-align: center;
    margin: 30px 0;
    color: #1c1c1e;
    font-size: 24px;
    flex-shrink: 0;
}

h2 {
    color: #1c1c1e;
    font-size: 20px;
    margin-bottom: 20px;
}

.game-board {
    width: 320px;
    height: 320px;
    margin: 0 auto;
    background-color: #f8f8f8;
    border: 2px solid #e0e0e0;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 1px;
}

.controls {
    margin-top: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.horizontal-controls {
    display: flex;
    gap: 40px;
}

button {
    width: 60px;
    height: 60px;
    border: none;
    border-radius: 30px;
    background-color: #007AFF;
    color: white;
    font-size: 24px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

button:active {
    background-color: #0051a8;
}

.game-actions {
    margin-bottom: 20px;
    display: flex;
    justify-content: center;
    gap: 10px;
}

.action-button {
    width: auto;
    height: 40px;
    padding: 0 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    background-color: #4CAF50;
}

.action-button:active {
    background-color: #388E3C;
}

.action-button[disabled] {
    background-color: #ccc;
    cursor: not-allowed;
}

#select-level {
    background-color: #FF9800;
}

#select-level:active {
    background-color: #F57C00;
}

.level-select {
    padding: 20px;
    text-align: center;
    height: calc(100% - 100px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.level-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin: 20px auto;
    max-width: 340px;
    padding-bottom: 20px;
}

.level-button {
    padding: 20px 15px;
    background: #f8f8f8;
    border: 2px solid #007AFF;
    border-radius: 10px;
    color: #007AFF;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s;
    height: auto;
    width: auto;
    white-space: pre-line;
    line-height: 1.4;
}

.level-button.completed {
    background: #007AFF;
    color: white;
}

.level-button.current {
    border-color: #4CAF50;
    color: #4CAF50;
}

.game-info {
    display: flex;
    justify-content: space-between;
    padding: 10px 20px;
    margin-bottom: 20px;
    font-size: 14px;
    color: #666;
}

/* 游戏状态控制 */
.game-board,
.controls,
.game-info {
    display: none;
}

.game-active .game-board,
.game-active .controls,
.game-active .game-info {
    display: flex;
}

.game-active .game-board {
    display: grid;
}

.game-active .level-select {
    display: none;
}

.level-select::-webkit-scrollbar {
    width: 6px;
}

.level-select::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.level-select::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

.level-select::-webkit-scrollbar-thumb:hover {
    background: #555;
}
  