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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--md-sys-color-background);
    color: var(--md-sys-color-on-surface);
    padding-top: 20px;
    padding-left: 20px;
    padding-right: 20px;
    min-height: 100vh;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    background-color: var(--md-sys-color-surface-container);
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

h1 {
    color: var(--md-sys-color-on-surface);
    margin-bottom: 30px;
    font-size: 28px;
    text-align: center;
}

.control-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 30px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

label {
    color: var(--md-sys-color-on-surface-variant);
    font-size: 14px;
    font-weight: 500;
}

input[type="number"] {
    background-color: var(--md-sys-color-background);
    border: 2px solid var(--md-sys-color-outline-variant);
    color: var(--md-sys-color-on-surface);
    padding: 10px 15px;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s;
}

input[type="number"]:focus {
    outline: none;
    border-color: #5865F2;
}

.button-group {
    display: flex;
    gap: 15px;
    margin-bottom: 30px;
}

button {
    flex: 1;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    color: var(--md-sys-color-on-surface);
}

.btn-start {
    background-color: #5865F2;
}

.btn-start:hover:not(:disabled) {
    background-color: #4752C4;
    transform: translateY(-1px);
}

.btn-stop {
    background-color: #ED4245;
}

.btn-stop:hover:not(:disabled) {
    background-color: #C03537;
    transform: translateY(-1px);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.preview-area {
    background-color: var(--md-sys-color-background);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    text-align: center;
    position: relative;
}

#preview {
    max-width: 100%;
    max-height: 500px;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    background: var(--md-sys-color-background);
}

.color-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 20px;
    background-color: #1a1b21;
    border-radius: 8px;
    margin-bottom: 20px;
}

.active-areas {
    padding: 20px 20px 10px 20px;
    background-color: var(--md-sys-color-background);
    border-radius: 8px;
    margin-bottom: 20px;
    min-height: 200px;
    max-height: 600px;
    overflow-y: auto;
    overflow-x: hidden;
}

.area-row {
    display: flex;
    flex-wrap: nowrap;
    gap: 5px;
    margin-bottom: 10px;
    align-items: flex-start;
    overflow-x: auto;
    white-space: nowrap;
}

.area-card {
    background-color: var(--md-sys-color-surface-container);
    border-radius: 6px;
    padding: 6px;
    border: 2px solid var(--md-sys-color-outline-variant);
    transition: all 0.3s ease;
    cursor: pointer;
    width: 60px;
    height: 45px;
    font-size: 9px;
    flex-shrink: 0;
}

.area-card:hover {
    border-color: #FF4444;
    box-shadow: 0 0 10px rgba(255, 68, 68, 0.3);
    transform: scale(1.02);
}

.area-card.active {
    border-color: #F0B232;
    box-shadow: 0 0 10px rgba(240, 178, 50, 0.3);
}

.area-info {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 4px;
}

.area-color {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    border: 1px solid var(--md-sys-color-outline-variant);
}

.area-pos {
    font-family: 'Courier New', monospace;
    font-size: 9px;
    color: #7289DA;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.area-change {
    font-family: 'Courier New', monospace;
    font-size: 9px;
    color: #F0B232;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

select {
    background-color: var(--md-sys-color-background);
    border: 2px solid var(--md-sys-color-outline-variant);
    color: var(--md-sys-color-on-surface);
    padding: 10px 15px;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s;
}

select:focus {
    outline: none;
    border-color: #5865F2;
}

.dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.dialog {
    background-color: var(--md-sys-color-surface-container);
    border-radius: 12px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    border: 2px solid var(--md-sys-color-outline-variant);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.dialog h2 {
    color: var(--md-sys-color-on-surface);
    margin-bottom: 20px;
    text-align: center;
}

.dialog-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.dialog input[type="text"],
.dialog input[type="number"] {
    background-color: var(--md-sys-color-background);
    border: 2px solid var(--md-sys-color-outline-variant);
    color: var(--md-sys-color-on-surface);
    padding: 10px 15px;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s;
    width: 100%;
    box-sizing: border-box;
}

.dialog input[type="text"]:focus,
.dialog input[type="number"]:focus {
    outline: none;
    border-color: #5865F2;
}

.dialog-buttons {
    display: flex;
    gap: 15px;
    justify-content: flex-end;
    margin-top: 25px;
}

.dialog-buttons button {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
}

.btn-cancel {
    background-color: #6c757d;
    color: white;
}

.btn-track {
    background-color: #28a745;
    color: white;
}

.tracking-section {
    background-color: var(--md-sys-color-background);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    display: none;
}

.tracking-item {
    background-color: var(--md-sys-color-surface-container);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    border: 2px solid var(--md-sys-color-outline-variant);
}

.tracking-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.tracking-title {
    color: var(--md-sys-color-on-surface);
    font-weight: 600;
    font-size: 16px;
}

.tracking-status {
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 12px;
    font-weight: 600;
}

.tracking-status.active {
    background-color: #28a745;
    color: white;
}

.tracking-status.inactive {
    background-color: #6c757d;
    color: white;
}

.tracking-info {
    color: var(--md-sys-color-on-surface-variant);
    font-size: 14px;
    margin-bottom: 10px;
}

.tracking-history {
    max-height: 150px;
    overflow-y: auto;
    background-color: var(--md-sys-color-background);
    border-radius: 6px;
    padding: 10px;
}

.history-entry {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 0;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    font-family: 'Courier New', monospace;
    font-size: 12px;
}

.history-entry:last-child {
    border-bottom: none;
}

.history-entry.changed {
    color: #F0B232;
}

.history-entry.unchanged {
    color: #7289DA;
}

.tracking-controls {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.tracking-controls button {
    padding: 5px 15px;
    font-size: 12px;
    border-radius: 4px;
}

.footer {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 15px 20px;
    margin-top: 15px;
    border-top: 1px solid var(--md-sys-color-outline-variant);
    color: #7289DA;
    font-size: 14px;
}

.footer a {
    color: #5865F2;
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
}

.color-box {
    display: block;
    width: 80px;
    height: 80px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    border: 2px solid #404252;
    transition: background-color 0.2s ease;
    background-color: #1a1b21;
}

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

.color-info h3 {
    color: #ffffff;
    margin-bottom: 8px;
}

.color-value {
    font-family: 'Courier New', monospace;
    color: #b0b0b0;
    margin: 4px 0;
}

.log-container {
    background-color: var(--md-sys-color-background);
    border-radius: 8px;
    padding: 20px;
    max-height: 300px;
    overflow-y: auto;
}

.log-container h3 {
    color: var(--md-sys-color-on-surface);
    margin-bottom: 15px;
}

.log-entry {
    padding: 8px 12px;
    margin-bottom: 8px;
    background-color: var(--md-sys-color-surface-container);
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.log-entry.change {
    border-left: 3px solid #F0B232;
}

.timestamp {
    color: #7289DA;
    font-size: 12px;
}

.message {
    color: var(--md-sys-color-on-surface-variant);
    text-align: center;
    padding: 40px;
    font-size: 18px;
}

.crosshair {
    position: absolute;
    width: 30px;
    height: 30px;
    border: 2px solid #F0B232;
    border-radius: 50%;
    pointer-events: none;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 10px rgba(240, 178, 50, 0.5);
}

.crosshair::before,
.crosshair::after {
    content: '';
    position: absolute;
    background-color: #F0B232;
}

.crosshair::before {
    width: 1px;
    height: 10px;
    left: 50%;
    top: -5px;
    transform: translateX(-50%);
}

.crosshair::after {
    height: 1px;
    width: 10px;
    top: 50%;
    left: -5px;
    transform: translateY(-50%);
}